Re: Diff between Primary key and non primary key select - Mailing list pgsql-general

From Greg Stark
Subject Re: Diff between Primary key and non primary key select
Date
Msg-id 87y94ij46y.fsf@stark.dyndns.tv
Whole thread Raw
In response to Diff between Primary key and non primary key select  (Deepa <kdeepa@midascomm.com>)
List pgsql-general
Deepa <kdeepa@midascomm.com> writes:

>         In the above result, I cannot able to see much difference between
> the time consumed using primary key and non-primary key value. Even in
> some cases, I can able to see that using non primary key value retrieves record faster
> than  using primary key.

Try running "analyze tablename". If you don't run analyze periodically
postgres won't know about changes in the data such as a table growing large
enough to warrant using an index.

If that doesn't help, run your query in psql with the word "explain" before it
and send the results. Also send the output of \d tablename.

explain will say exactly what postgres is doing to run your query. It looks
like the query with the primary key may not be using an index.

--
greg

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Diff between Primary key and non primary key select
Next
From: Jeff Eckermann
Date:
Subject: Re: Postgres Databases growing without much reason