pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Ferdinand Smit <ferdinand@telegraafnet.nl>
Cc: pgsql-admin@postgresql.org
Subject: Re: Index problems
Date: Wed, 3 Dec 2003 07:56:41 -0800 (PST)
Message-ID: <20031203074800.T28610@megazone.bigpanda.com> (raw)
In-Reply-To: <200312031154.48776.ferdinand@telegraafnet.nl>
References: <200312031154.48776.ferdinand@telegraafnet.nl>


On Wed, 3 Dec 2003, Ferdinand Smit wrote:

> Hi,
>
> When trying to explain a developer of our organisation the reson why the index
> was'nt used, i was confused my self.
>
> The simple question is: Why does the analyzer only use the index when the

There are a fiew things going on:

First, the statistics are overestimating the number of matching rows (by
say a factor of 3 in the first query).  You may wish to increase the
statistics target (alter table test alter column r set statistics <n>)
for something greater than 10, try 20 or 100 and re-analyze the table and
see if that lowers the estimated costs for the index scan.

Second, it's also possible that on your system random_page_cost should be
lower than 4.  Lowering that value lowers the estimated cost for index
scans.

Finally, it's also possible that the table is reasonably grouped by values
of r but that the statistics aren't realizing that fact. What does the row
in pg_statistic for that column show?



view thread (2+ messages)

Message-ID: <20031203074800.T28610@megazone.bigpanda.com>
Permalink:  ../20031203074800.T28610@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20031203074800.T28610@megazone.bigpanda.com

 · 

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-admin@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, ferdinand@telegraafnet.nl
  Subject: Re: Index problems
  In-Reply-To: <20031203074800.T28610@megazone.bigpanda.com>
  References: <200312031154.48776.ferdinand@telegraafnet.nl> <20031203074800.T28610@megazone.bigpanda.com>

* 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