Re: Query is slow when run for first time; subsequent execution is fast

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Query is slow when run for first time; subsequent execution is fast
Дата
Msg-id CAMkU=1zFFxF74BVpwbsT1s-yY-KmW8Ya6CZkM0PDfvZ8uupF9A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Query is slow when run for first time; subsequent execution is fast  (Nandakumar M <m.nanda92@gmail.com>)
Ответы RE: Query is slow when run for first time; subsequent execution isfast  ("POUSSEL, Guillaume" <guillaume.poussel@sogeti.com>)
Re: Query is slow when run for first time; subsequent execution isfast  (Michael Paquier <michael.paquier@gmail.com>)
Список pgsql-performance
On Fri, Jan 12, 2018 at 12:03 AM, Nandakumar M <m.nanda92@gmail.com> wrote:
Hello Jeff,

Thanks for the insights.

>Don't keep closing and reopening connections.

Even if I close a connection and open a new one and execute the same query, the planning time is considerably less than the first time. Only when I restart the Postgres server then I face high planning time again.

Oh.  I've not seen that before.  But then again I don't often restart my server and then immediately run very large queries with a stringent time deadline.
 
You can try pg_prewarm, on pg_statistic table and its index.  But I'd probably just put an entry in my db startup script to run this query immediately after startng the server, and let the query warm the cache itself.

Why do you restart your database often enough for this to be an issue?

Cheers,

Jeff

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

Предыдущее
От: Mark Kirkwood
Дата:
Сообщение: Re: HDD vs SSD without explanation
Следующее
От: "POUSSEL, Guillaume"
Дата:
Сообщение: RE: Query is slow when run for first time; subsequent execution isfast