Skip site navigation (1) Skip section navigation (2)

Re: Postgres not using indexes

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, "Lawrence Cohan" <LCohan(at)web(dot)com>
Subject: Re: Postgres not using indexes
Date: 2011-03-30 18:51:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Lawrence Cohan <LCohan(at)web(dot)com> wrote:
> Please see updated attachment that includes the tables involved in
> the simple query below and all their indexes.
Well, that rules out a couple common problems (comparisons between
different types and incorrect indexing).
> We believe that the performance issue is due to the query not
> using any index but doing seq scans instead
So it appears.
> and this is very little related to the knowledge from the link you
> posted below.
Oh, but it is very much related.  The PostgreSQL optimizer looks at
all the various plans available, calculates a cost for each, and run
the one with the lowest calculated cost.  Various configuration
parameters affect the costing calculations, and thus the plan
ultimately chosen.  To get good plans, the configuration must
accurately model the actual costs for your particular machine.
Having seen that the types match and the indexes look usable, it
must come down to something in your configuration.  Probably the
easiest way to show that is to run the query here and post the
> As you can see we picked a simple query with INNER JOIN between
> two indexed tables where postgres 8.3 and 9.0 decides to not use
> existing indexes for whatever reason.
The reason is that with the configuration you're using, PostgreSQL
calculates the cost of using the index as being higher than the cost
of a sequential scan.  The trick is to find where your configuration
is wrong, so that the calculated costs better match the reality on
your server.

In response to

pgsql-bugs by date

Next:From: Lawrence CohanDate: 2011-03-30 19:05:15
Subject: Re: Postgres not using indexes
Previous:From: Lawrence CohanDate: 2011-03-30 18:32:14
Subject: Re: Postgres not using indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group