Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group