Re: [PERFORM] Getting an optimal plan on the first execution of a pl/pgsql function

2015-12-14 Thread David G. Johnston
On Mon, Dec 14, 2015 at 11:53 AM, Pedro França wrote: > I have a really busy function that I need to optimize the best way I can. > This function is just a nested select statement that is requested several > times a sec by a legacy application. I'm running a

[PERFORM] Getting an optimal plan on the first execution of a pl/pgsql function

2015-12-14 Thread Pedro França
I have a really busy function that I need to optimize the best way I can. This function is just a nested select statement that is requested several times a sec by a legacy application. I'm running a PostgreSQL 9.4 on a CentOS 6; The indexes are in place but I've noticed that it is only used after

Re: [PERFORM] Getting an optimal plan on the first execution of a pl/pgsql function

2015-12-14 Thread Tom Lane
"David G. Johnston" writes: > On Mon, Dec 14, 2015 at 11:53 AM, Pedro França > 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

Re: [PERFORM] Getting an optimal plan on the first execution of a pl/pgsql function

2015-12-14 Thread Pedro França
Thank you for the replies guys, The output of auto-explain pratically comfirms what you say (sorry there are some portuguese words in there). I will try pgpooler. < 2015-12-14 18:10:02.314 BRST >LOG: duration: 0.234 ms plan: Query Text: SELECT teqp.eqpID, teqp.eqpveiID AS veiID, tcb.tcbID,