pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
To: Lawrence Cohan <LCohan@web.com>
Subject: Re: Postgres not using indexes
Date: Wed, 30 Mar 2011 13:51:24 -0500
Message-ID: <4D93355C020000250003BFAA@gw.wicourts.gov> (raw)
In-Reply-To: <965AA5440EAC094E9F722519E285ACEDAC5E66A55F@WWCEXCHANGE.web.web.com>
References: <965AA5440EAC094E9F722519E285ACEDAC5E66A53D@WWCEXCHANGE.web.web.com>
	<4D9317D3020000250003BF7B@gw.wicourts.gov>
	<965AA5440EAC094E9F722519E285ACEDAC5E66A556@WWCEXCHANGE.web.web.com>
	<4D9322E8020000250003BF8C@gw.wicourts.gov>
	<965AA5440EAC094E9F722519E285ACEDAC5E66A55F@WWCEXCHANGE.web.web.com>

Lawrence Cohan <LCohan@web.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
results:
 
http://wiki.postgresql.org/wiki/Server_Configuration
 
> 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.
 
-Kevin



view thread (23+ messages)  latest in thread

Message-ID: <4D93355C020000250003BFAA@gw.wicourts.gov>
Permalink:  ../4D93355C020000250003BFAA@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4D93355C020000250003BFAA@gw.wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, LCohan@web.com
  Subject: Re: Postgres not using indexes
  In-Reply-To: <4D93355C020000250003BFAA@gw.wicourts.gov>
  References: <965AA5440EAC094E9F722519E285ACEDAC5E66A53D@WWCEXCHANGE.web.web.com> <4D9317D3020000250003BF7B@gw.wicourts.gov> <965AA5440EAC094E9F722519E285ACEDAC5E66A556@WWCEXCHANGE.web.web.com> <4D9322E8020000250003BF8C@gw.wicourts.gov> <965AA5440EAC094E9F722519E285ACEDAC5E66A55F@WWCEXCHANGE.web.web.com> <4D93355C020000250003BFAA@gw.wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox