Re: Berserk Autovacuum (let's save next Mandrill) - Mailing list pgsql-hackers
From | David Rowley |
---|---|
Subject | Re: Berserk Autovacuum (let's save next Mandrill) |
Date | |
Msg-id | CAApHDvrdVpYQUqk5uTR-iVwnW=JbEwX86zngCj5v06Ug77MPVw@mail.gmail.com Whole thread Raw |
In response to | Re: Berserk Autovacuum (let's save next Mandrill) (Laurenz Albe <laurenz.albe@cybertec.at>) |
Responses |
Re: Berserk Autovacuum (let's save next Mandrill)
|
List | pgsql-hackers |
On Fri, 6 Mar 2020 at 03:27, Laurenz Albe <laurenz.albe@cybertec.at> wrote: > > On Thu, 2020-03-05 at 19:40 +1300, David Rowley wrote: > > 1. I'd go for 2 new GUCs and reloptions. > > autovacuum_vacuum_insert_threshold (you're currently calling this > > autovacuum_vacuum_insert_limit. I don't see why the word "limit" is > > relevant here). The other GUC I think should be named > > autovacuum_vacuum_insert_scale_factor and these should work exactly > > the same way as autovacuum_vacuum_threshold and > > autovacuum_vacuum_scale_factor, but be applied in a similar way to the > > vacuum settings, but only be applied after we've checked to ensure the > > table is not otherwise eligible to be vacuumed. > > I disagree about the scale_factor (and have not added it to the > updated version of the patch). If we have a scale_factor, then the > time between successive autovacuum runs would increase as the table > gets bigger, which defeats the purpose of reducing the impact of each > autovacuum run. My view here is not really to debate what logically makes the most sense. I don't really think for a minute that the current auto-vacuums scale_factor and thresholds are perfect for the job. It's true that the larger a table becomes, the less often it'll be vacuumed, but these are control knobs that people have become accustomed to and I don't really think that making an exception for this is warranted. Perhaps we can zero out the scale factor by default and set the threshold into the millions of tuples. We can have people chime in on what they think about that and why once the code is written and even perhaps committed. Lack of a scale_factor does leave people who regularly truncate their "append-only" tables out in the cold a bit. Perhaps they'd like index-only scans to kick in soon after they truncate without having to wait for 10 million tuples, or so. > > 10. I'm slightly worried about the case where we don't quite trigger a > > normal vacuum but trigger a vacuum due to INSERTs then skip cleaning > > up the indexes but proceed to leave dead index entries causing indexes > > to become bloated. It does not seem impossible that given the right > > balance of INSERTs and UPDATE/DELETEs that this could happen every > > time and the indexes would just become larger and larger. > > I understand. > > This might particularly be a problem with larger tables, where > a normal autovacuum is rare because of the scale_factor. > > Perhaps we can take care of the problem by *not* skipping index > cleanup if "changes_since_analyze" is substantially greater than 0. > > What do you think? Well, there is code that skips the index scans when there are 0 dead tuples found in the heap. If the table is truly INSERT-only then it won't do any harm since we'll skip the index scan anyway. I think it's less risky to clean the indexes. If we skip that then there will be a group of people will suffer from index bloat due to this, no matter if they realise it or not. > > 11. We probably do also need to debate if we want this on or off by > > default. I'd have leaned towards enabling by default if I'd not > > personally witnessed the fact that people rarely* increase auto-vacuum > > to run faster than the standard cost settings. I've seen hundreds of > > servers over the years with all workers busy for days on something > > they'll never finish quickly enough. We increased those settings 10x > > in PG12, so there will be fewer people around suffering from that now, > > but even after having reduced the vacuum_cost_delay x10 over the PG11 > > settings, it's by no means fast enough for everyone. I've mixed > > feelings about giving auto-vacuum more work to do for those people, so > > perhaps the best option is to keep this off by default so as not to > > affect the people who don't tune auto-vacuum. They'll just suffer the > > pain all at once when they hit max freeze age instead of more > > gradually with the additional load on the workers. At least adding > > this feature gives the people who do tune auto-vacuum some ability to > > handle read-only tables in some sane way. > > > > An alternative way of doing it would be to set the threshold to some > > number of million tuples and set the scale_factor to 0.2 so that it > > only has an effect on larger tables, of which generally people only > > have a smallish number of. > > Yes, I think that disabling this by default defeats the purpose. Perhaps the solution to that is somewhere else then. I can picture some sort of load average counters for auto-vacuum and spamming the logs with WARNINGs if we maintain high enough load for long enough, but we'd likely be better just completely overhauling the vacuum cost settings to be a percentage of total effort rather than some fixed speed. That would allow more powerful servers to run vacuum more quickly and it would also run more quickly during low load periods. We'd just need to sample now and again how long vacuuming a series of page takes then sleep for a time based on how long that took. That's not for this patch though. > Updated patch attached. Thanks. I've not looked yet as I really think we need a scale_factor for this. I'm interested to hear what others think. So far both Justin and I think it's a good idea.
pgsql-hackers by date: