Skip site navigation (1) Skip section navigation (2)

Re: Query times change by orders of magnitude as DB ages

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Richard Neill <rn214(at)cam(dot)ac(dot)uk>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query times change by orders of magnitude as DB ages
Date: 2009-11-25 19:01:38
Message-ID: 603c8f070911251101r4abb015dj8f2146d6364ba7b0@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Wed, Nov 25, 2009 at 7:27 AM, Richard Neill <rn214(at)cam(dot)ac(dot)uk> wrote:
> Sergey Aleynikov wrote:
>>
>> Hello,
>>
>>> * Is there any way I can nail the query planner to a particular query
>>> plan,
>>> rather than have it keep changing its mind?
>>
>> All these setting leads to choosing different plans. If you have small
>> number of complex sensitive queires, you can run explain on them with
>> correct settings, then re-order query (joins, subselects) according to
>> given query plan, and, before running it, call
>>
>> set local join_collapse_limit = 1;
>> set local from_collapse_limit = 1;
>
> It's a simple query, but using a complex view. So I can't really re-order
> it.

Almost all queries can be reordered to some degree, but you might have
to inline the view into the main query to actually be able to do it.
Forcing a particular query plan in the manner described here is
generally sort of a last resort, though.  Usually you want to figure
out how to tune things so that the query planner picks the right plan
by itself - that's sort of the point of having a query planner...

...Robert

In response to

pgsql-performance by date

Next:From: Faheem MithaDate: 2009-11-25 22:54:46
Subject: Re: query optimization
Previous:From: Robert HaasDate: 2009-11-25 17:27:22
Subject: Re: query optimization

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group