Re: Slow planning time - Mailing list pgsql-admin

From Tom Lane
Subject Re: Slow planning time
Date
Msg-id 26165.1450884264@sss.pgh.pa.us
Whole thread Raw
In response to Slow planning time  (Scott Neville <scott.neville@bluestar-software.co.uk>)
Responses Re: Slow planning time
List pgsql-admin
Scott Neville <scott.neville@bluestar-software.co.uk> writes:
> We have a database that for some reason has started to be really slow at planning all queries.  The database is
runningversion 9.4.2 since July 28th (it was freshly installed then - compiled from source).  The response time is
fairlysporadic, but the quickest plan time I have seen (on any query) using explain analyze is 39ms with an execution
timeof 1ms, however we have slow query logging on and we are getting queries taking over 6000 ms in the planning stage
withthen only a few ms to execute.  There is nothing complex about the queries so even something like this: 
> select max(datetime) from audit;
> (where datetime is an indexed field takes 200ms to plan and 0.5ms to execute).

> The databases are involved in a replication chain so I have
> M1 -> S1 -> S2
> I have restarted S2 and S1 and this appears to have made the problem go away (though for how long....).  S1 has a
replicationslot listed on M1. 

Please clarify: the slowness occurs on the slaves but not the master?

I am suspicious that the problem has to do with bloat in pg_statistic,
which I will bet that your homegrown vacuuming protocol isn't covering
adequately.  I concur with Kevin's nearby advice that you'd be better
off to forget that and use 10 or so autovacuum workers; you can use
autovacuum_cost_limit to throttle their I/O impact, and still be a
lot better off than with just 1 worker.

There is probably something else going on that's replication-specific,
but I'm not sufficiently up on that aspect of things to theorize.

            regards, tom lane


pgsql-admin by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: Slow planning time
Next
From: Artem Tomyuk
Date:
Subject: pg_dump