Re: Forcing postgresql to use an index - Mailing list pgsql-performance

From Eugene Morozov
Subject Re: Forcing postgresql to use an index
Date
Msg-id 87iqfsadg2.fsf@eugenemorozov.name
Whole thread Raw
In response to Forcing postgresql to use an index  (Eugene Morozov <eugene@cactus-mouse.com>)
List pgsql-performance
Scott Marlowe <scott.marlowe@gmail.com> writes:

> On Tue, Sep 8, 2009 at 8:12 AM, Eugene Morozov<eugene@cactus-mouse.com> wrote:
> OK, you need to look a little deeper at what's happening here.  The
> pgsql query planner looks at a lot of things to decide if to use seq
> scan or and index.  If you look at your row estimates versus actual
> rows returned, you'll see they're off, sometimes by quite a bit.
> Particularly the ones near the top of your query plans. There are a
> few things you can do to help out here.  Increase default stats target
> and re-analyse, increase effective_cache_size to reflect the actual
> size of data being cached by your OS / filesystem / pgsql, and then
> lowering random_page_cost.

Thanks to all who answered. Your answers were really helpful, I've
split the query in two (couldn't make Django to use JOIN here) and was
able to speed it up by a factor of 10!
Eugene

pgsql-performance by date:

Previous
From: Kevin Kempter
Date:
Subject: partitioning max() sql not using index
Next
From: Heikki Linnakangas
Date:
Subject: Re: partitioning max() sql not using index