Re: EXPLAIN ANALYZE not considering primary and unique indices!

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: EXPLAIN ANALYZE not considering primary and unique indices!
Date: 2007-08-27 18:44:18
Message-ID: 200708271144.18213@hal.medialogik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday 27 August 2007 05:21, Sanjay <skpatel20(at)gmail(dot)com> wrote:
>Wondering why it is not using the index, which would have
> been
> automatically created for the primary key.

Because you not only have just one row in the whole table, 100% of them will
match the query. In short, one page fetch for a seq scan is faster than
first looking it up in an index and then fetching the same page.

set enable_seqscan=false;

--
"Government big enough to supply everything you need is big enough to take
everything you have ... the course of history shows that as a government
grows, liberty decreases." -- Thomas Jefferson

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Decibel! 2007-08-27 18:55:47 Re: [HACKERS] Undetected corruption of table files
Previous Message Bill Moran 2007-08-27 18:43:48 Re: EXPLAIN ANALYZE not considering primary and unique indices!