Re: Diff between Primary key and non primary key select

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Diff between Primary key and non primary key select
Date: 2003-02-14 15:02:29
Message-ID: 87y94ij46y.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Deepa <kdeepa(at)midascomm(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Eckermann 2003-02-14 15:06:07 Re: Postgres Databases growing without much reason
Previous Message Richard Huxton 2003-02-14 14:55:29 Re: Diff between Primary key and non primary key select