Re: BUG #6702: SELECT Query on INDEX

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <alokrawat0212(at)gmail(dot)com>,<pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6702: SELECT Query on INDEX
Date: 2012-06-22 15:12:52
Message-ID: 4FE4452402000025000489C7@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

<alokrawat0212(at)gmail(dot)com> wrote:

> I created a Index in postgres.Now i want to fire select query in
> this Index and check data.
>
> Please tell me how to perform this???

This is not a bug. Please post any follow-ups or similar questions
to pgsql-general or pgsql-novice; or if it is a performance
question, try pgsql-performance.

To answer the question, as long as we're here, PostgreSQL uses a
cost-based optimizer -- so it will consider using the index on any
queries for the table which reference indexed columns. On a tiny
table (a few thousand rows or less), or if you are selecting more
than about 10% of the rows from the table, it is unlikely to use the
index because a simple scan of the heap is almost always faster.
Load up the tables with a lot of data and select for equality
against an indexed column using a value present in a small number of
rows, and you are likely to see the index used.

If you think the optimizer is not choosing the fastest plan, please
read this page:

http://wiki.postgresql.org/wiki/SlowQueryQuestions

-Kevin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message jeff 2012-06-23 00:36:36 BUG #6704: ALTER EXTENSION postgis SET SCHEMA leaves dangling relations
Previous Message Ryan Kelly 2012-06-22 15:02:11 Re: BUG #6702: SELECT Query on INDEX