Re: Optimizer not using index when it should

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Rob Messer <rrmesser(at)yahoo(dot)com>
Cc: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimizer not using index when it should
Date: 2003-04-29 13:04:09
Message-ID: 1051621449.76105.9.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> What can I do to fix this -- is there something I am missing about
> setting statistics or some configuration variable I can change? Any
> insights would be greatly appreciated. Thank you,

If you look at the estimates for cost, the index scan is more expensive
by ~1/8th. But as you've shown, it's not.

You might try adjusting the random_page_cost down to something more
appropriate for your hardware and situation.

Do testing... this may cause other queries to use an index scan when
they should have been doing a sequential scan. Mistakenly using an
index can be a much more costly error (hence the high default
random_page_cost).

--
Rod Taylor <rbt(at)rbt(dot)ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert John Shepherd 2003-04-29 13:53:18 Best ODBC cursor and lock types for fastest reading?
Previous Message SZŰCS Gábor 2003-04-29 13:01:21 Query Plan far worse in 7.3.2 than 7.2.1