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.
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.
In response to
pgsql-performance by date
|Next:||From: Tom Lane||Date: 2004-08-30 20:48:05|
|Subject: Re: seqscan instead of index scan |
|Previous:||From: Greg Stark||Date: 2004-08-30 20:18:39|
|Subject: Re: Why does a simple query not use an obvious index?|