Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Christopher Kings-Lynne wrote:
>> With this Bruce, is there any reason this was accepted now, and not
>> several years ago when I first submitted it? :D
> Uh, I wasn't around then. (No, that isn't going to work.) Uh, no idea.
> I think there is a sense now that doing BETWEEN in gram.y isn't so bad
> because the optimizer can deal with the AND conditation better than
> perhaps it could in the past, but that is total guess.
No, that's exactly it: the original patch was rejected because it made
BETWEEN unoptimizable, IIRC. The change from then to now likely has
more to do with improvements in the optimizer than with the content of
the BETWEEN ASYMMETRIC patch itself.
We are still not totally done on this issue --- as Peter pointed out,
it'd be a lot nicer to represent "a BETWEEN b AND c" as a special
expression node that evaluates "a" only once. BETWEEN ASYMMETRIC is
worse because it may evaluate b and c multiple times too. The missing
part is to teach the optimizer to plan such a thing correctly ...
regards, tom lane