is this a bug or do I not understand the query planner?

Поиск
Список
Период
Сортировка
Искать
От
Rob Prowel
Тема
is this a bug or do I not understand the query planner?
Дата
Msg-id
20051103233648.44895.qmail@web60019.mail.yahoo.com
Список
Дерево обсуждения
Re: is this a bug or do I not understand the query planner? "Qingqing Zhou" <zhouqq@cs.toronto.edu>
two almost identical queries: one searches for 

read in ('N','n') 

and the other searches for 

read in ('Y','y').

the (explain) SQL statement says that one uses the
index on the (read) field and the other does a
sequential table scan.  Why!!!????  I can think of no
logical reason for this behavior.



usenet=# \d+ article
                            Table "public.article"
 Column  |          Type          |          Modifiers
      | Description 
---------+------------------------+------------------------------+-------------
 msg     | integer                | not null          
          | 
 thedate | date                   | not null          
          | 
 subject | character varying(300) |                   
          | 
 lines   | integer                | not null default 0
          | 
 read    | character(1)           | not null default
'N'::bpchar | 
 ng      | integer                | not null default 0
          | 
 author  | integer                | not null default 0
          | 
Indexes:
    "article_pkey" PRIMARY KEY, btree (msg)
    "article_read" btree ("read")
Has OIDs: yes

usenet=# explain select * from article where read in
('Y','y');
                                         QUERY PLAN   
                                     
--------------------------------------------------------------------------------------------
 Index Scan using article_read, article_read on
article  (cost=0.00..4.03 rows=1 width=107)
   Index Cond: (("read" = 'Y'::bpchar) OR ("read" =
'y'::bpchar))
(2 rows)

usenet=# explain select * from article where read in
('N','n');
                            QUERY PLAN                
            
-------------------------------------------------------------------
 Seq Scan on article  (cost=0.00..68661.02
rows=2018135 width=107)
   Filter: (("read" = 'N'::bpchar) OR ("read" =
'n'::bpchar))
(2 rows)




		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
В списке pgsql-bugs по дате отправления
От: Alvaro Herrera
Дата:
От: Qingqing Zhou
Дата:
FAQ