Re: Getting an optimal plan on the first execution of a pl/pgsql function
От | Tom Lane |
---|---|
Тема | Re: Getting an optimal plan on the first execution of a pl/pgsql function |
Дата | |
Msg-id | 5607.1450125717@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Getting an optimal plan on the first execution of a pl/pgsql function ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: Getting an optimal plan on the first execution of a
pl/pgsql function
|
Список | pgsql-performance |
"David G. Johnston" <david.g.johnston@gmail.com> writes: > On Mon, Dec 14, 2015 at 11:53 AM, Pedro França <pedro.franca@golsat.com.br> > wrote: >> When I test with EXPLAIN ANALYZE after the first execution, the query runs >> really fast but the aplication sessions call the function only once and >> then are terminated. I need that the first execution use the actual >> optimized plan. > Your problem that the performance improvement is > seen due to caching effects. If you throw away the cache you loose the > improvement. Yeah. And it's not only the function itself, it's catalog caches and a bunch of other stuff. Basically, you should expect that the first few queries executed by any PG session are going to be slower than those executed later. If you can't fix your application to hold sessions open for a reasonable amount of time, use a connection pooler to do it for you (pgpooler for instance). regards, tom lane
В списке pgsql-performance по дате отправления: