Re: Query only slow on first run

Поиск
Список
Период
Сортировка
От Kevin Kempter
Тема Re: Query only slow on first run
Дата
Msg-id 200711270957.07818.kevin@kevinkempterllc.com
обсуждение исходный текст
Ответ на Query only slow on first run  (cluster <skrald@amossen.dk>)
Список pgsql-performance
On Tuesday 27 November 2007 09:33:36 cluster wrote:
> I have a query that takes about 7000 ms in average to complete the first
> time it runs. Subsequent runs complete in only 50 ms. That is more than
> a factor 100 faster! How can I make the query perform good in the first
> run too?
>
> Query and output from both first and second run of Explain Analyze is
> pasted here:
>
> http://rafb.net/p/yrKyoA17.html
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match


The query is faster the second run because the data pages were pulled into the
buffer pool during the first run. I would suggest using the explain plan from
the first run and test your changes on a recently started instance (or at
least on an instance where enough activity has transpired to effectively
rotate the buffer pages).

/Kevin

В списке pgsql-performance по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: Query only slow on first run
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Query only slow on first run