Re: BETWEEN [SYMMETRIC | ASYMMETRIC]

From: Thomas Swan <tswan-lst(at)ics(dot)olemiss(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: BETWEEN [SYMMETRIC | ASYMMETRIC]
Date: 2001-01-10 16:10:51
Message-ID: 5.0.2.1.0.20010110100840.01b21ff8@tangent.ics.olemiss.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 1/9/2001 10:29 PM, Tom Lane wrote:
>Thomas Swan <tswan-lst(at)ics(dot)olemiss(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-01-10 16:43:03 Re: Re: Beta2 ... ?
Previous Message Pete Forman 2001-01-10 15:45:38 Re: AW: Re: tinterval - operator problems on AIX