Re: partial index on boolean, problem with v8.0.0rc1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: partial index on boolean, problem with v8.0.0rc1
Date: 2004-12-13 18:46:13
Message-ID: 26878.1102963573@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx> writes:
> In both cases, tables are filled with ~10m of rows, "is_read" is false in the
> 1st case, and "NULL" in the 2nd. I did "VACUUM FULL ANALYSE" after both
> imports.

> Here's the problem: in the 2nd case, planner wouldn't choose an index scan
> using partial index on "is_read" for the following queries:

This is the same problem noted by Mike Mascari a couple weeks ago:
ANALYZE does not store any statistics about an all-null column.
So there are no stats and the default decision is not to risk an
indexscan

> explain select * from user_msg where is_read=true;
> explain select * from user_msg where is_read is true;
> explain select * from user_msg where is_read;

Only the first of these could possibly match the partial index anyway.
In theory the planner could recognize that the first and third are
equivalent spellings of the same condition, but it does not presently
do so.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Phil Endecott 2004-12-13 18:58:13 Re: Temporary tables and disk activity
Previous Message Josh Berkus 2004-12-13 18:43:28 Re: pg_restore taking 4 hours!