Re: Index problems

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Ferdinand Smit <ferdinand(at)telegraafnet(dot)nl>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Index problems
Date: 2003-12-03 15:56:41
Message-ID: 20031203074800.T28610@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


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?

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bruce Momjian 2003-12-03 22:06:46 Re: Misplaced modifier in Postgresql license
Previous Message Ferdinand Smit 2003-12-03 10:54:48 Index problems