How to create index on only some of the rows

From: A B <gentosaker(at)gmail(dot)com>
To: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: How to create index on only some of the rows
Date: 2011-02-07 14:00:54
Message-ID: AANLkTik2jC2fKzQXSNqkd6manZVp=aOrkfrUiSr1662O@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

How do you create an index for only some of the rows in a table? I
read in the docs:

"The expression used in the WHERE clause can refer only to columns of
the underlying table, but it can use all columns, not just the ones
being indexed. Presently, subqueries and aggregate expressions are
also forbidden in WHERE. The same restrictions apply to index fields
that are expressions. "

So until this changes, can you just add a boolean field to tell if the
column should be used in the index, and then run "create index ....
where use_in_index = true" or are there other (better?) ways of doing
this?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andre Lopes 2011-02-07 14:12:59 Slow Inserts, two different scenarios.
Previous Message markw 2011-02-07 12:54:48 Re: Subquery for column names of tablefunc crosstab queries