"Tom Lane" <tgl@sss.pgh.pa.us> writes:
> Gregory Stark <gsstark@mit.edu> writes:
>> I imagine you've thought of this already but just in case, the cost of the
>> function call has to be combined with the selectivity to get this right. If
>> you can do an expensive but very selective clause first and save 100 cheap
>> calls that almost always return true it may still be worthwhile.
>
> I've thought of it, but I haven't figured out a reasonable algorithm for
> ordering the clauses in view of that. Have you?
Hum, I hadn't tried. Now that I think about it it's certainly not obvious.
And picturing the possible failure modes I would rather it execute cheap
expressions more often than necessary than call some user-defined perl
function that could be doing i/o or involve waiting on other resources any
more than absolutely necessary. So I guess what you originally described is
safest.
-- Gregory Stark EnterpriseDB http://www.enterprisedb.com