Re: BETWEEN [SYMMETRIC | ASYMMETRIC] - Mailing list pgsql-hackers

From Thomas Swan
Subject Re: BETWEEN [SYMMETRIC | ASYMMETRIC]
Date
Msg-id 5.0.2.1.0.20010110100840.01b21ff8@tangent.ics.olemiss.edu
Whole thread Raw
In response to BETWEEN [SYMMETRIC | ASYMMETRIC]  ("Robert B. Easter" <reaster@comptechnews.com>)
Responses Re: Re: BETWEEN [SYMMETRIC | ASYMMETRIC]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
At 1/9/2001 10:29 PM, Tom Lane wrote:
>Thomas Swan <tswan-lst@ics.olemiss.edu> writes:
> > Shouldn't be much of problem... where would I start to look... :)
>
>Well, the Right Way To Do It would be to invent a new expression node
>type that implements both kinds of BETWEEN.  Right now, the parser
>expands A BETWEEN B AND C into "A >= B AND A <= C", which is perfectly
>correct according to the letter of the spec, but it implies evaluating
>the subexpression A twice, which sucks.  Besides which, this doesn't

Actually if it were possible to look at the values before expanding.  You 
could reorder the expression so that it was always the case that B < C, 
then your cost would only be one comparison plus the sequential scan.


>readily generalize to the SYMMETRIC case.  I'd make a new expr node
>type with three subexpressions and a SYMMETRIC bool flag.  If you chase
>down all the places where CaseExpr nodes are processed, and add a
>BetweenExpr case in parallel, you'll have it made.
>
>                         regards, tom lane



pgsql-hackers by date:

Previous
From: Pete Forman
Date:
Subject: Re: AW: Re: tinterval - operator problems on AIX
Next
From: Peter Eisentraut
Date:
Subject: Re: Re: Beta2 ... ?