Re: Doesn't use index, why? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Doesn't use index, why?
Date
Msg-id 200101090609.BAA26593@candle.pha.pa.us
Whole thread Raw
In response to Re: Doesn't use index, why?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
> In this case the planner is doing *exactly* the right thing; it is
> smarter than you are.  If you want to prove it, force the planner to
> use an indexscan by doing SET ENABLE_SEQSCAN TO OFF.  Then time the
> query, and compare the runtime against the seqscan version.
>
> The bottom line here is that a query that needs to touch more than a
> few percent of the rows in a table is better off being done as a
> seqscan.

The only other workaround is to CLUSTER the table on an index, then
force an index scan.  That _may_ be faster.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: 7.1 PL/pgSQL EXECUTE Command
Next
From: Tom Lane
Date:
Subject: Re: WAL questions