Re: BETWEEN Help

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-patches(at)postgresql(dot)org
Subject: Re: BETWEEN Help
Date: 2002-04-15 00:06:05
Message-ID: 200204150006.g3F065a17587@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> Yup, that's one place that will need to be taught about it.
>
> > That was actually a reason I was wondering if it was worth changing our
> > current BETWEEN code. The optimizer already is complicated and trying
> > to do BETWEEN rather than the more simpler statements didn't seem like a
> > win.
>
> Actually, an explicit representation of BETWEEN will *help* the
> optimizer; right now it has to try to recognize range restrictions
> by matching up '>' and '<' clauses. That's a mess already, and I
> had no intention of trying to extend that logic to recognize the
> clause structures that BETWEEN SYMMETRIC would put out if it weren't
> a primitive node type. But if it's a node then recognizing it is
> a no-brainer. See clausesel.c.

Oh, good. Another issue is that "nocachefunc() BETWEEN 1 and 2" should
call the function only once, which my AND/OR hack didn't do. I can
imagine random() working strangely with BETWEEN.

I just tried:

test=> select 1 where random() between 0.49999 and 0.5000;

in current CVS and it clearly is printing 1 more often that it should. :-(

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2002-04-15 00:33:31 Re: Commands/ directory reorganisation
Previous Message Tom Lane 2002-04-15 00:01:58 Re: BETWEEN Help