The check for parallel_safe should be even cheaper than cost comparisonso I think it's better to do that first. The attached patch does thisand also updates the comment to mention the requirement about beingparallel-safe.
ThanksRichard