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.96) (envelope-from ) id 1vMrPP-003y7D-0f for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Nov 2025 17:28:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMrPN-00C9kZ-0y for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Nov 2025 17:28:25 +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.96) (envelope-from ) id 1vMrPN-00C9kR-02 for pgsql-hackers@lists.postgresql.org; Sat, 22 Nov 2025 17:28:25 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vMrPL-000vNR-1G for pgsql-hackers@postgresql.org; Sat, 22 Nov 2025 17:28:25 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-b737502f77bso430961266b.2 for ; Sat, 22 Nov 2025 09:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763832502; x=1764437302; 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=SAsUlRlhr/Qsr5d9Z6SixIBSDC+hQv0gjL88uXsLoHs=; b=HEqZ6kW7sxZH49l4L+qzEUm3IA91hHMRKtS1ZS+Izg4aD4yHbCIo1hdUyMpJRErr7M 264c3WMbS3hZ/fpnI1UK3+erB9fQXY6voNBDA4Cj8k9mYUvOB9cY/F0Zhd7fJn4p08A+ akgsRUQV+0CHdlNpVBlNdR+61Er4CnjiZCHEsb6tmpGNyp2j+bw8hK7q5+XeSBXEBB6d nGsWGM+FouPu0MrxbC9FJN6yVxypLY3sEDtOobAUil4ObrryOeJtYx5LlSxPaPF4ES93 zZDOcS7vo+kBMvoRPda6b0xjy8LxVhzyKAv+EFIPtUtD4+QpNcJOCCshqSGEVpYNUHRG aJVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763832502; x=1764437302; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SAsUlRlhr/Qsr5d9Z6SixIBSDC+hQv0gjL88uXsLoHs=; b=bJMJxC9HyWiDRFvhy8HZBig523CPxdh7dqlEG8SjUH3luVvcxjv1Mi/qaw51qAraG1 onEqpELXcvKAceezg8RWzcOUcaxOdm5WCEEShpei8qUskO7vCPHd6QAfdTG5LAV7ddTT 22EDQ2ho6ug1Z6ZR7cmxWU0yCka5rm6NEv1EnqpkuwibZjFloktNNCB9G+IHFoEJ2O4X SR1qSz9vYjHYKwOo34r15i5/lXl0xWF6vPzOp0wWH5sJJH8ojBqzoJtnO6UEI2uCMAjw WGns/ljAMiBsRFHUJ/hwn8u9TOd6kQujQSykDjHF4oeU/Atf21SJS26D5VkE8xPvfQEG ydQg== X-Forwarded-Encrypted: i=1; AJvYcCX5PQMxLs9dH94ddJXisVE9GuRjCdTpECPtixQSrJWxufQuH7b7/2OSs0qTsEW8oJ/PM84djnaF3DNoDbHn@postgresql.org X-Gm-Message-State: AOJu0YwQGLMZNYN7uVMtU/X13u6k6d+2P1kyO4Mo0pJKUWiCXQgXr4uB PIUNHY4IagM3GYwf8yWEaIdZVTEAcjJPRvO7Ym5hcm5DU/wLyKszTdpx2QAhnQD9B8gimdlmXzn bfqf2ZWIZ+3ttPHpxafZHtAbyt7dyZEs= X-Gm-Gg: ASbGncsQ9rKC6TjYGOYz2lqSAbv0pLF6PJU1BYexOKXzlc4f8dI+G8lGETK41S3STCc YqDbDYPvG8rrbgPzU/XzssxP+/gEOrujw5WDPULeviRVlaE6TBShSe32ooP9KnljtNue42pPqOJ rbY/zAC0mqLVtDLvcxxMIERoV+u5Ep3rKS2H5kR5D5VxuuB/ZHzE6hFX+nbD9MgVIoxrZzsI78M xH3j9E0QQJq9yOusb9y7cxQ76/CyXwureoa+PzOxhRQ2UGZTwcBbkPcxMY6YIWgTZ7EY/o= X-Google-Smtp-Source: AGHT+IGZgEVIhiMdc9x4Ale8YB9yFUItdh6QV/PiFJyRTKH8fiq+VQINLshtENfC39+Hkoy3Vp4EkkB9p6XAixGOjD8= X-Received: by 2002:a17:906:4fce:b0:b73:a319:e8be with SMTP id a640c23a62f3a-b7671a221cfmr755267066b.57.1763832501536; Sat, 22 Nov 2025 09:28:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Sat, 22 Nov 2025 11:28:10 -0600 X-Gm-Features: AWmQ_blJM2bclWCg4HRoxpHNvDsrtm9-bCzYE6SenCeUfqH4Az-kZ6y-rMrhjeI Message-ID: Subject: Re: another autovacuum scheduling thread To: Robert Haas Cc: David Rowley , Nathan Bossart , Robert Treat , 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 > > I suspect the most likely area the new prioritisation order could > > cause issues is from the lack of randomness. Will multiple workers > > working into the same database be more likely to bump into each other > > somehow in a bad way? Maybe that's a good area to focus testing. > > I agree that lack of randomness could cause problems, but I don't see > how it could cause regressions, because the current system isn't > random, either. Even if the order of pg_class is unpredictable, it may > (depending on the workload) not change very much from one day to the > next. > > > Yeah partly, but mostly I just really doubt that this matters that > > much. It's been said on this thread already that prioritisation isn't > > as important as the autovacuum-configured-to-run-too-slowly issue, and > > I agree with that. I just find it hard to believe that the highly > > volatile pg_class order has been just perfect all these years and that > > sorting by percentage-over-threshold-desc will make things worse > > overall. There was mention that pg_catalog tables are first in > > pg_class, but I don't really agree with that as if I create some new > > tables on a fresh database, I see those getting lower ctids than any > > pg_catalog table. The space for that is finite, but there's no > > shortage of other reasons for user tables to become mentioned in > > pg_class before catalogue tables as the database gets used. I see that > > table_beginscan_catalog() uses SO_ALLOW_SYNC too, so there's an extra > > layer of randomness from sync scans. I don't recall any complaints > > from the order autovacuum works on tables, so, to me, it just seems > > strange to think that the volatile order of pg_class just happened to > > be right all these years. I suspect what's happening is that the extra > > bloat or stale statistics that people get as a result of the > > pg_class-order autovacuum just gets unnoticed, ignored or attended to > > via adjustments to the corresponding scale_factor reloption. > > Interesting. I don't have any real knowledge of how jumbled-up the > order of pg_class is on real production systems, and I agree that if > the answer is "it's usually quite jumbled up" then that is good news > for this patch. In any case, I'm not trying to say that prioritization > is an intrinsically bad idea, because I don't believe that. What I'm > trying to say is that there's a limited number of ways for this patch > to make things worse What I have not been able to prove from my tests is that the processing order of tables by autovacuum will actually make things any better or any worse. My tests have been short 30 minute tests that count how many vacuum cycles tables with various DML activity and sizes received. I have not found much difference. I am also not sure how valuable these short-duration tests are either. On the field is where the real test occurs and it may be discovered that the new strategy improves the majority of the cases, and there may also be cases where the existing strategy is somehow better. Having the ability to go back to the existing behavior seems like the best way we can roll this out and learn over time. These may be the only two strategies we will ever need, or we may find out that a third strategy in which individual tables are assigned a prioritization score will also be useful. -- Sami