Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vF0lj-00625w-EU for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Nov 2025 01:51:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vF0lf-002gCq-CV for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Nov 2025 01:50:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vF0lf-002gCi-0H for pgsql-hackers@lists.postgresql.org; Sat, 01 Nov 2025 01:50:58 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vF0lb-005LUC-2S for pgsql-hackers@postgresql.org; Sat, 01 Nov 2025 01:50:57 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-378ccb8f84aso31663861fa.3 for ; Fri, 31 Oct 2025 18:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761961854; x=1762566654; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=GdA/mAySbJ59mKS44pa/xM9fvAStlSARaFiwYcmgPeU=; b=Z2VJLnnI2CrQMuXzdBjaSpGSNgarkaYvyiBqf0K5C+zx5zXMYqwc70/cBSqo8Y1xSV F9LEVQL8nzIRbfZpyX1cCQ3bAs41gRKa+MptYKa3lfs6OXKYllCUp8+GTwQZlfUUG+zQ ApFoTzoo7ddkGzvivMecBFPagLHZZX57Adu8drhd0A64jeITKQvbPbwyr4lQRifgKbgd yici8IKhNIve2Ubw3QSisq4D+3RJUB5+Nag5pmN0WD7lw1HT2p2oh/Cw98BuHf7f9q3D AaimL1Ko9hzXham3uShnj3ehW87LzE+MCNIqMCr7o5WjJY79Bii9uqoXah+rwxInxktZ 21jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761961854; x=1762566654; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GdA/mAySbJ59mKS44pa/xM9fvAStlSARaFiwYcmgPeU=; b=v2dGYagznGF7j3Zn7RdGeek5gSvHAEPBt5NGJ7h/5qz5pN5Y+hjVY+MUuIMrlGx6M6 7SnmxcmytplYbkbBbAN/XdwAQdVHc0LS1EWH7XX5OfghQEUVRehgBg7ATVUDM8bExHa2 E45VfjPzSeAQKWS/BsonQnn/1KegW+/WmiF3+G8AdU53SxSwjlr9PwKb2uhJjuAOawl3 WP7sEq5+uIlvpkiDDG8Pl0tWsLzqAMyNDH4MRidFSPlNXAiEF/fo0E2HaiOEnnOlwyMn iAojR3AxddRwAYRJ40dg00U2+fRRY5wagn1OZi80sEOmX8Anlv/K71T903+UonS/8+CA kMAg== X-Forwarded-Encrypted: i=1; AJvYcCWQNM3wIBZLVRYxDQgP1oxu9lhYpy+S3wpa+acZrs2k6mbL8lksfZjJnhCxozvkg07bD3V/6BRtAe4chGOP@postgresql.org X-Gm-Message-State: AOJu0YxfMNSM+Y2EvVZ1glFI9ae81xkCQtQnKLyNgSVM7FeI5gz/yrOb DxX4+ZPHyzRwY17yBWr2b6sGPKtf/s5c0pynhT6Z3gowyeex4sdMjVyZvWdvaCzQVjGekt34W4d 7GLmov6Rzm5MgBglkyPo0I/WAPFzYTpo= X-Gm-Gg: ASbGncuf7079vQqVHp8IQFlut69YIzToqz3ff2Mp3lKyvozGK+Rgg5HFFdxWfyGA45V +ul5YrFzbBw3ffdZo2SmRN3c0AKROz/78LUXeSTsDBoZ/ZJVsCHBbAOzQBK4PFxpptKVPLDz3bW w01R5c6rQsfLxp21BzeKNvsiem43qREEys9O/0RmNLNlaWml0Gtpkz86haGaw1NPdqqXQ/4aMbb vXoLrV3pPMnZL+/qiPWSclmXsuoktXFBR24Ao+vNtHsgi+o+LnRlAn9Vd9G7D39NLRWN5Sj6uVn DdOSg3V5oQKDsXapwlhs2ECRVApesmFytdpf1q76dBYfrnHActCkpd2eeXdn9Q== X-Google-Smtp-Source: AGHT+IFhxBZjvM8yD66uAch5Rmj3idKv7JLLzozmvhkRdJ9y087zPdF9imuY+hEMENkaPkb8McI3zenw1whKZCr/Q94= X-Received: by 2002:a05:6512:238c:b0:592:f931:b540 with SMTP id 2adb3069b0e04-5941d527267mr1964449e87.22.1761961853787; Fri, 31 Oct 2025 18:50:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Sat, 1 Nov 2025 14:50:42 +1300 X-Gm-Features: AWmQ_bnf1WJRbAKR-dpVQ55nqaO_jVylmbBMJWiULXrFT_6jX8cOeuPXFm5wHbI Message-ID: Subject: Re: another autovacuum scheduling thread To: Nathan Bossart Cc: Sami Imseih , Robert Haas , Jeremy Schneider , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 1 Nov 2025 at 09:12, Nathan Bossart wrote: > > On Thu, Oct 30, 2025 at 07:38:15PM -0500, Sami Imseih wrote: > > The results above show what I expected: the batch tables receive higher > > priority, as seen from the averages of autovacuum and autoanalyze runs. > > This behavior is expected, but it may catch some users by surprise after > > an upgrade, since certain tables will now receive more attention than > > others. Longer tests might also show more bloat accumulating on heavily > > updated tables. In such cases, a user may need to adjust autovacuum > > settings on a per-table basis to restore the previous behavior. > > Interesting. From these results, it almost sounds as if we're further > amplifying the intended effect of commit 06eae9e. That could be a good > thing. Something else I'm curious about is datfrozenxid, i.e., whether > prioritization keeps the database (M)XID ages lower. I wonder if it would be more realistic to throttle the work simulation to a certain speed with pgbench -R rather than having it go flat out. The results show that quite a bit higher "rows_inserted" for the batch_tables with the patched version. Sami didn't mention any changes to vacuum_cost_limit, so I suspect that autovacuum would be getting quite behind on this run, which isn't ideal. Rate limiting to something that the given vacuum_cost_limit could keep up with seems more realistic. The fact that the patched version did more insert work in the batch tables does seem a bit unfair as that gave autovacuum more work to do in the patched test run which would result in the lower-scoring tables being neglected more in the patched version. This makes me wonder if we should log the score of the table when the autovacuum starts for the table. We do calculate the score again in recheck_relation_needs_vacanalyze() just before doing the vacuum/analyze, so maybe the score can be stored in the autovac_table struct and displayed somewhere. Maybe along with the log_autovacuum_min_duration / log_autoanalyze_min_duration would be useful. It might be good in there for DBA analysis to give some visibility on how bad things got before autovacuum got around to working on a given table. If we logged the score, we could do the "unpatched" test with the patched code, just with commenting out the list_sort(tables_to_process, TableToProcessComparator); It'd then be interesting to zero the log_auto*_min_duration settings and review the order differences and how high the scores got. Would the average score be higher or lower with patched version? I'd guess lower since the higher scoring tables would tend to get vacuumed later with the unpatched version and their score would be even higher by the time autovacuum got to them. I think if the average score has gone down at the point that the vacuum starts, then that's a very good thing. Maybe we'd need to write a patch to recalculate the "tables_to_process" List after a table is vacuumed and autovacuum_naptime has elapsed for us to see this, else the priorities might have become too outdated. I'd expect that to be even more true when vacuum_cost_limit is configured too low. David