Re: [HACKERS] Optimizer & boolean syntax

2002-11-23 Thread Daniele Orlandi
Tom Lane wrote: Only two of them are logically equivalent. Consider NULL. Ohhh IS NOT TRUE or IS NOT FALSE also match NULL, I never knew this :) Even for the first two, assuming equivalence requires hard-wiring an assumption about the behavior of the "bool = bool" operator; which is a user-r

Re: [HACKERS] Optimizer & boolean syntax

2002-11-22 Thread scott.marlowe
On Thu, 21 Nov 2002, Stephan Szabo wrote: > > On Thu, 21 Nov 2002, Christopher Kings-Lynne wrote: > > > > > > "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

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Tom Lane
Daniele Orlandi <[EMAIL PROTECTED]> writes: > The problem is the opposite... so, effectively, seems that the optimizer > considers "monitored" and "monitored=true" as two different expressions... Check. > The viceversa is analog and we also can see that the syntax "monitored > is true" is consi

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Daniele Orlandi
Stephan Szabo wrote: On Thu, 21 Nov 2002, Daniele Orlandi 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 equiva

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Stephan Szabo
On Thu, 21 Nov 2002, Christopher Kings-Lynne wrote: > > > > "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 > > > >

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Christopher Kings-Lynne
> > > "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

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Christopher Kings-Lynne
> > Not that I see the point of indexing booleans, but hey :) > > If one of the values is much more infrequent than the other, you can > probably get a substantial win using a partial index, can't you? Yes, I thought of the partial index after I wrote that email :) Chris -

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread scott.marlowe
On Thu, 21 Nov 2002, Christopher Kings-Lynne wrote: > > > 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.

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread scott.marlowe
On Thu, 21 Nov 2002, Christopher Kings-Lynne wrote: > > > 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.

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Alvaro Herrera
On Thu, Nov 21, 2002 at 02:45:34PM -0800, Christopher Kings-Lynne wrote: > > > 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? > Not that I see the point of indexing boolean

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Christopher Kings-Lynne
> > 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

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Stephan Szabo
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

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Christopher Kings-Lynne
> > 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

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Stephan Szabo
On Thu, 21 Nov 2002, Daniele Orlandi 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 pres

Re: [HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Robert Treat
Using the famous WAG tech, in your first query the optimizer has to evaluate monitored for each record to determine its value. Robert Treat On Thu, 2002-11-21 at 13:39, Daniele Orlandi wrote: > > Are those two syntaxes eqivalent ? > > select * from users where monitored; > select * from users w

[HACKERS] Optimizer & boolean syntax

2002-11-21 Thread Daniele Orlandi
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 :) Tested on RC1: template1=# create table a (a boolean, b text); CREATE TABLE inserted ~18000 rows with