Re: vacuum analyze query performance - help me understand
От | Tom Lane |
---|---|
Тема | Re: vacuum analyze query performance - help me understand |
Дата | |
Msg-id | 601313.1755627596@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | vacuum analyze query performance - help me understand (Scot Kreienkamp <Scot.Kreienkamp@la-z-boy.com>) |
Ответы |
RE: vacuum analyze query performance - help me understand
|
Список | pgsql-general |
Scot Kreienkamp <Scot.Kreienkamp@la-z-boy.com> writes: > That command should vacuum analyze all tables in all databases, and it was proven that it worked as the last vacuum andanalyze dates on the tables in all databases are showing dates from 2am today. I take it from this that you have autovacuum turned off and you think a once-a-day manual vacuum run is an adequate replacement? > So here's the problem: We ran a (admittedly poorly written) select query against a subset of tables which performed poorly. Then we ran a vacuum analyze against just those tables involved in that query, then ran the same query again, whichperformed exponentially better. I verified by comparing before and after explains that the query plan did not changebetween runs of the query, the only changes were stats like cost, rows, width, time, etc. If the plan didn't change then the stats updates weren't very relevant. I am guessing that the actual problem was that those tables were full of dirty rows, and the VACUUM (not the ANALYZE part) got rid of dead rows, set hint bits on recently-updated rows, and generally did a lot of janitorial work that makes subsequent table scans faster. Turning off autovacuum is an anti-pattern. (Running a PG version that's four years past EOL is also an anti-pattern, but you knew that. Should I ask whether it's at least the final 9.6 minor release?) regards, tom lane
В списке pgsql-general по дате отправления: