[PERFORM] Performance difference between Slon master and slave

2015-12-14 Thread Matthew Lunnon
Hello all, I hope someone can help me with this. Postgres 9.4.4 Slon 2.2.4 Linux I am using slony-i to replicate a production database which is in the order of 70GB. I have a reasonably complex select query that runs in 40 seconds on the master but takes in the region of 30-40 minutes on the

Re: [PERFORM] Performance difference between Slon master and slave

2015-12-14 Thread Mattthew Lunnon
Hi Jim, Thanks for your response. Yes the tables have been analysed and I have also re-indexed and vacuumed the slave database. Regards Matthew Sent from my iPad > On 14 Dec 2015, at 17:49, Jim Nasby wrote: > >> On 12/14/15 11:16 AM, Matthew Lunnon wrote: >>

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

Re: [PERFORM] Performance difference between Slon master and slave

2015-12-14 Thread Jim Nasby
On 12/14/15 11:16 AM, Matthew Lunnon wrote: Inspecting the execution plan shows that there are some differences, for example, the slave is using a HashAggregate when the master is simply grouping. There also seems to be a difference with the ordering of the sub plans. Have you tried analyzing

[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,