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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 25, 2009 at 7:27 AM, Richard Neill <rn214@xxxxxxxxx> 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

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux