Re: How to create index on only some of the rows

From: Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com>
To: A B <gentosaker(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to create index on only some of the rows
Date: 2011-02-07 14:42:06
Message-ID: A0BE2E23-0D0E-4E28-930D-06C29AE449E3@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Feb 7, 2011, at 11:00 PM, A B wrote:
> 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?

If you want you can do that Or You can use proper where clause as given below:
CREATE INDEX indexname on tablename(columname) where condition;

example:
create index directed_graph_idx on directed_graph(node_from) where node_from in ('A','B');

Thanks & Regards,
Vibhor Kumar
vibhor(dot)kumar(at)enterprisedb(dot)com
Blog:http://vibhork.blogspot.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2011-02-07 14:47:03 Re: Question about switchover with PG9 replication
Previous Message Vick Khera 2011-02-07 14:32:38 Re: Directing Partitioned Table Searches