Re: seqscan instead of index scan

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Martin Sarsale <martin(at)emepe3(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: seqscan instead of index scan
Date: 2004-08-30 20:36:30
Message-ID: 873c24ics1.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2004-08-30 20:48:05 Re: seqscan instead of index scan
Previous Message Greg Stark 2004-08-30 20:18:39 Re: Why does a simple query not use an obvious index?