Optimizer & boolean syntax - Mailing list pgsql-hackers

From Daniele Orlandi
Subject Optimizer & boolean syntax
Date
Msg-id 3DDD2857.9070102@orlandi.com
Whole thread Raw
Responses Re: Optimizer & boolean syntax  (Robert Treat <xzilla@users.sourceforge.net>)
Re: Optimizer & boolean syntax  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-hackers
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 just one true (just to make an index scan  meaningful)....

template1=# vacuum analyze a;
VACUUM
template1=# explain select * from a where a;                     QUERY PLAN
---------------------------------------------------- Seq Scan on a  (cost=0.00..802.64 rows=1 width=11)   Filter: a
(2 rows)

template1=# explain select * from a where a=true;                          QUERY PLAN
-------------------------------------------------------------- Index Scan using a_a on a  (cost=0.00..2.01 rows=1
width=11)  Index Cond: (a = true)
 
(2 rows)

Bye!

--  Daniele Orlandi Planet Srl



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: xBSD shmem doc deficiency
Next
From: Thomas O'Connell
Date:
Subject: Re: [GENERAL] Bug with sequence