Re: Optimizer & boolean syntax - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: Optimizer & boolean syntax
Date
Msg-id 20021121141628.Y99995-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Optimizer & boolean syntax  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
On Thu, 21 Nov 2002, Christopher Kings-Lynne wrote:

> > > Are those two syntaxes eqivalent ?
> > >
> > > select * from users where monitored;
> > > select * from users where monitored=true;
> > >
> > > If the answer is yes, the optimimer probably doesn't agree with you :)
> >
> > That depends on the definition of equivalent.  They presumably give the
> > same answer (I'm assuming monitored is a boolean), but the latter has
> > something that's considered an indexable condition and I believe the
> > former does not (even with enable_seqscan=off the former syntax
> > appears to give a sequence scan, usually a good sign it's not considered
> > indexable).
>
> I think his point is that they _should_ be equivalent.  Surely there's
> something in the optimiser that discards '=true' stuff, like 'a=a' should be
> discarded?

I figure that's what he meant, but it isn't what was said. ;)

"col" isn't of the general form "indexkey op constant" or "constant op
indexkey" which I presume it's looking for given the comments in
indxpath.c.  I'm not sure what the best way to make it work would be given
that presumably we'd want to make col IS TRUE/FALSE use an index at the
same time (since that appears to not do so as well).




pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Optimizer & boolean syntax
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: Optimizer & boolean syntax