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: Correct syntax to create partial index on a boolean column
Date: 2011-12-15 04:43:31
Message-ID: CABs1bs1WkUXWq1W9EjZvL7aH2mtTK678C19SYXWFTPX9D8WVMA@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!

Mike

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Duncan 2011-12-15 04:47:07 Re: Philosophical question
Previous Message Darren Duncan 2011-12-15 04:41:00 Re: Philosophical question