Re: Correct syntax to create partial index on a boolean column

From: Mike Christensen <mike(at)kitchenpc(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Correct syntax to create partial index on a boolean column
Date: 2011-12-15 05:54:02
Message-ID: CABs1bs3DJjtxBLayAw_8n8t2pUtVJj87Rer7TwhzR4xg=a8WLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> For the boolean column Foo in Table1, if I want to index all values of
> TRUE, is this syntax correct?
>
> CREATE INDEX IDX_MyIndex ON Table1(Foo) WHERE Foo;
>
> The query:
>
> SELECT * FROM Table1 WHERE Foo;
>
> should use the index, and:
>
> SELECT * FROM Table1 WHERE NOT Foo;
>
> should not, correct?
>
> I just want to make sure I don't need an operator on the WHERE clause.  Thanks!

FYI, I've posted this on StackOverflow too in case anyone wants to
score some points..

http://stackoverflow.com/questions/8514923/postgres-is-this-the-right-way-to-create-a-partial-index-on-a-boolean-column

I'm 90% sure this is the right way to do it though.

Mike

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Xiaobo Gu 2011-12-15 06:12:40 question about \encoding option of psql
Previous Message Chris Angelico 2011-12-15 05:34:36 Re: Philosophical question