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

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Rob Prowel <tempest766(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: is this a bug or do I not understand the query planner?
Date: 2005-11-03 23:59:27
Message-ID: 200511040059.27965.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Rob Prowel wrote:
> 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.

Imagine a table with one million 'Y' and one 'N'. Searching for the
first should not use an index, searching for the second should. A
similar case probably applies here. I hope that is logical enough for
you. :)

In general, if you disagree with a plan choice, you should provide
evidence that the chosen plan is in practice worse then the one you
would have preferred.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message venki 2005-11-04 10:15:23 how to install postgres 8.0.4 in RHEL4
Previous Message Qingqing Zhou 2005-11-03 23:55:03 Re: is this a bug or do I not understand the query planner?