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 1vC1rh-0086yo-El for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 20:24:52 +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 1vC1rf-00BXmu-NP for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 20:24:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vC1rf-00BXjf-9o for pgsql-hackers@lists.postgresql.org; Thu, 23 Oct 2025 20:24:50 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vC1rc-003PWB-2K for pgsql-hackers@postgresql.org; Thu, 23 Oct 2025 20:24:49 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-367444a3e2aso14851541fa.2 for ; Thu, 23 Oct 2025 13:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761251087; x=1761855887; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MzPG/KohBbhB605W1iB6o4aAMRPyfJaiF1RB4K3H5Do=; b=IuujdvZxFFU/30+oxX8hG/Qm+wFAtpvSmYIPJ5RB5ovoSbwCxdTgJGmiAGVwD9qqVZ CeWjnK4Ai4ib4r80RpfNg6TBtH/y4/xMwYgnBgaoY9rsaIDXq0wu213KLx+zEd9tyq7R TuhHXBo7D1ooz8mxE3RIa5JS6I/2XE+veeUiUoISDDMKKMR316pMcm17Lyr0kgA5vl9o HAQot42+ecojZMENDPgUOfovO22cRq6XPQlxWXn8YRLVsVCX0djwXd2s8H/g0Abo/XyH 7y1lA5kzQzTTGTsZtLy1Y2sp9cxSd+Meinko0if91J1V7zLpy3RNiC/bHRDX0NkTofYH Mfyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761251087; x=1761855887; h=content-transfer-encoding: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=MzPG/KohBbhB605W1iB6o4aAMRPyfJaiF1RB4K3H5Do=; b=WwHpkBty6z1mkWQeIqP4cWqp+btG0Bvd0DEu94yF5DlMKXBsaYbzbp/LI2dHGboe4O PnHblA9fOB49PM6Cwqe09RmU085uaal1LE8+DuY8nFZL84643LSgHTh5e/EZoUFIXp83 Ei8spDTa0AeXjEHt3G/FYmXySYJjOhfhGGEgQm07t/hQiSP4BJiCGZQS6NvAp1iuf8I3 AQxNKJKfcM0FVsTSEr1IcC1itDwfyqbvctALw7QtnCghOGAjXKEn8+9hAn4TNeBOHZ2B bHWorc3Q72llog+zlokOw5U2qM3bFjvIGsqhW27m3DYYMZ7KrlVEp2RdEFbNeMelqio1 tYbA== X-Forwarded-Encrypted: i=1; AJvYcCXOfECJg0oe6VaF5Y7eJ1jby8Q+qZU8bDMaNFhXN9pA5+9IQ+GvdW9l1j3ZBTcqknHNP42T1L61N3qKOgpZ@postgresql.org X-Gm-Message-State: AOJu0YyvR1OhdpacttUo7IiqQOE+hS4iAxN7wu0AOVkVfWwmB+4IP6hG xB7sMnFjHRpI8yWUW+AIwtpkQu6koKN+7mxU0pfUhAT6xhO3OTd2La5iiq1YhGWp0xu+9eTSKbL f/IS+LNXx5wkyl5acBIOLb5qXFK0bekA= X-Gm-Gg: ASbGnctQHzsF3vpQDMyEAJHoaPGA2wxA+nFqnTQNKsk5IyHhsfOFBSTtGHyYAxoJZlL pg6v8I2mwHtr+iJZLkq7aZYtvnBk5+qEhv4TTFJk9fYokm046yBUzEVvc/kVIK5ZhrRYBnQq98m oSgLisbcWE0rrrcuJUbxdC44gjGtvjb8uSRC60CTkiFZ54ZnsX50UZs68llih9PRy2RWNlRp8Kg A+oqkkOmHM63bmJN81MZK+XHfHPIoDk4eF0Bb8JS3AA/fgcQQ7xHoh5gWwusWZleSJw+Fc81C4w aRUZ+7YCg+NFhjGr8L/7jdf35IOqfc/bQr+cQZwkfysyMTOImt8= X-Google-Smtp-Source: AGHT+IHRMMl2HEVyBr3uWol14OK1OeYsQ1J0+tjECZlZWhSWaHR8LwKZazD+L7sS/pGGlcmDu2BplckmSmDFIFmSyq4= X-Received: by 2002:a2e:ab81:0:b0:371:fb14:39bb with SMTP id 38308e7fff4ca-378e433a94amr23601fa.16.1761251086897; Thu, 23 Oct 2025 13:24:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Fri, 24 Oct 2025 09:24:34 +1300 X-Gm-Features: AWmQ_bnVXfDVlMX9gZsP68kNP7I1OT3ORpf8PR-BrVYFcG1INt-ww614vpkiFvw Message-ID: Subject: Re: another autovacuum scheduling thread To: Sami Imseih Cc: Nathan Bossart , Robert Haas , Jeremy Schneider , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 24 Oct 2025 at 08:33, Sami Imseih wrote: > Yeah, you=E2=80=99re correct, the list already exists; sorry I missed tha= t. My > main concern is > the additional overhead of the sort operation, especially if we have > many eligible > tables and an aggressive autovacuum_naptime. It is true that there are reasons that millions of tables could suddenly become eligible for autovacuum work with the consumption of a single xid, but I imagine sorting the list of tables is probably the least of the DBAs worries for that case as sorting the tables_to_process list is going to take a tiny fraction of the time that doing the vacuum work will take. If your concern is that the sort could take too large a portion of someone's 1sec autovacuum_naptime instance, then you also need to consider that the list isn't likely to be very long as there's very little time for tables to become eligible in such a short naptime, and if the tables are piling up because autovacuum is configured to run too slowly, then lets fix that at the root cause rather than be worried about improving one area because another area needs work. If we think like that, we'll remain gridlocked and autovacuum will never be improved. TBH, I think that mindset has likely contributed quite a bit to the fact that we've made about zero improvements in this area despite nobody thinking that nothing needs to be done. There are also things that could be done if we were genuinely concerned and had actual proof that this could reasonably be a problem. sort_template.h would reduce the constant factor of the indirect function call overhead by quite a bit. On a quick test here with a table containing 1 million random float8 values, a Seq Scan and in-memory Sort, EXPLAIN ANALYZE reports the sort took about 21ms: (actual time=3D172.273..193.824). I really doubt anyone will be concerned with 21ms when there's a list of 1 million tables needing to be autovacuumed. David