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

From: Bruno Wolff III <bruno(at)wolff(dot)to>
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:59:05
Message-ID: 20041213185905.GA11248@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 13, 2004 at 20:18:57 +0200,
Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx> wrote:
>
> 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:
>
> 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;
>
> In the 1st case, partial index was used for the first query.

Note that whatever = TRUE is not equivalent to whatever IS TRUE.
The latter will return FALSE if whatever is NULL, while the former will return
NULL in that case.

There are also some limitations on the optimizer recognizing equivalent
varients of an expression. This might cause a problem with the third
select example.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-12-13 19:04:11 Re: Temporary tables and disk activity
Previous Message Phil Endecott 2004-12-13 18:58:13 Re: Temporary tables and disk activity