Re: seqscan instead of index scan - Mailing list pgsql-performance

From Greg Stark
Subject Re: seqscan instead of index scan
Date
Msg-id 873c24ics1.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: seqscan instead of index scan  (Martin Sarsale <martin@emepe3.net>)
List pgsql-performance
Another option here is to use a partial index. You can index on some other
column -- perhaps the column you want the results ordered by where the where
clause is true.

Something like:

create index t_idx on t (name) where c>0 and d>0;

then any select with a matching where clause can use the index:

select * from t where c>0 and d>0 order by name

Could scan the index and not even have to sort on name.

--
greg

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: Why does a simple query not use an obvious index?
Next
From: Tom Lane
Date:
Subject: Re: seqscan instead of index scan