Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkTpb-0004K5-2p for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 17:55:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkTpZ-000843-18 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Apr 2023 17:55:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkTpY-00083u-Ll for pgsql-hackers@lists.postgresql.org; Thu, 06 Apr 2023 17:55:28 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pkTpV-001I0J-GQ for pgsql-hackers@postgresql.org; Thu, 06 Apr 2023 17:55:28 +0000 Received: by mail-lj1-x236.google.com with SMTP id z42so41442999ljq.13 for ; Thu, 06 Apr 2023 10:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680803724; x=1683395724; 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=Cn4aUOr6WbhLJBYV5LX0fSG+GLfqYoTxUxtyFUb/Kv4=; b=a2Hx4WZ8KcxtCbgMVnSg3pA78pzaeoloH36opwZDBbGmhFaJxb664+W2ie4VTGpVhD pDjrSUhaUjKRVskoYUDEscrnaqujapL6IziDdB24doloYyNNQVEkic0RmXWx9SWPtWv8 xq5DqLrT6ha9blM85mS93ydVi6d/DzWAGoha1B3QAe8L4AOWGSTYs6bqULi/AcWeonWi OHNdMamgce1qTb4p6vi5xjwK5zEObp4Exa0uqNKT6ni8Q6Q6AVHLQwLHR+nu0WGB24Vb 7iKlVwaLZlJjPRqxc/9yDZZ13XfwnVzPI7uULErdARSlkVYl2rL89kCg42e4Fp8xAeSa fO+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680803724; x=1683395724; 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=Cn4aUOr6WbhLJBYV5LX0fSG+GLfqYoTxUxtyFUb/Kv4=; b=d7js8nvAz29L8CD75oCbS679j5SyMSD2DSDJR/5YOhvLIAILXFOqoOnB7JFKOn4PMW o/iyYRxzidsx84jzCZaa+emVSn6UVqvtA2V9IEueBujig+SmN57PpNLW/FmSl95OBFX0 pPmvTt4VorxTqA+rIOiqcg7wsXEudDN74e2nj+J6+O4u1K/e38k9Wy7z+bTPbtZHV7le YjLUTZJF7rYn9yZm3SZExOkFqduHeAqxfx9qbjaKwpB9u1duotrSTysctnX4vytXCrHV +aEa0YfWyS6B7iYK3Cf4hv6duVlFgSwm+SN+hdPK1ke7seON2Liish77LfPxrrbDh8Ln tayg== X-Gm-Message-State: AAQBX9fzgQmdx3fBzHhMQMaVZoVTB0ojQ5LXEQw/gnaGOpnpL4l6ddJs x+0DrJNQZmFkjZCVgTQ05oZDc5+uGcci3deMSec= X-Google-Smtp-Source: AKy350YuSrg8bsYrlalcpJ8uy3b1GDOgtvrnNuXRrWOoPfcG9G4kqhHEy6r9Jd7z6HofOXAnS4YZzutNYnJzqy7vOO0= X-Received: by 2002:a2e:240b:0:b0:2a6:de0:79af with SMTP id k11-20020a2e240b000000b002a60de079afmr3536456ljk.10.1680803724169; Thu, 06 Apr 2023 10:55:24 -0700 (PDT) MIME-Version: 1.0 References: <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> <20230329.173456.1185961934810139447.horikyota.ntt@gmail.com> <935191FB-083B-4060-89FC-466F61FAA391@yesql.se> <1252075.1680547394@sss.pgh.pa.us> <20230403190837.qubpnwugfe2k2g46@awork3.anarazel.de> <7E06F879-7E20-4A6A-862F-CA72CDC9A323@yesql.se> <800860D2-AEE7-4D23-A5C0-9182EC252554@yesql.se> In-Reply-To: From: Robert Haas Date: Thu, 6 Apr 2023 13:55:12 -0400 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Peter Geoghegan Cc: Daniel Gustafsson , Melanie Plageman , Andres Freund , Tom Lane , Masahiko Sawada , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila 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 Wed, Apr 5, 2023 at 4:59=E2=80=AFPM Peter Geoghegan wrote: > I think that I agree. I think that the difficulty of tuning autovacuum > is the actual real problem. (Or maybe it's just very closely related > to the real problem -- the precise definition doesn't seem important.) I agree, and I think that bad choices around what the parameters do are a big part of the problem. autovacuum_max_workers is one example of that, but there are a bunch of others. It's not at all intuitive that if your database gets really big you either need to raise autovacuum_vacuum_cost_limit or lower autovacuum_vacuum_cost_delay. And, it's not intuitive either that raising autovacuum_max_workers doesn't increase the amount of vacuuming that gets done. In my experience, it's very common for people to observe that autovacuum is running constantly, and to figure out that the number of running workers is equal to autovacuum_max_workers at all times, and to then conclude that they need more workers. So they raise autovacuum_max_workers and nothing gets any better. In fact, things might get *worse*, because the time required to complete vacuuming of a large table can increase if the available bandwidth is potentially spread across more workers, and it's very often the time to vacuum the largest tables that determines whether things hold together adequately or not. This kind of stuff drives me absolutely batty. It's impossible to make every database behavior completely intuitive, but here we have a parameter that seems like it is exactly the right thing to solve the problem that the user knows they have, and it actually does nothing on a good day and causes a regression on a bad one. That's incredibly poor design. The way it works at the implementation level is pretty kooky, too. The available resources are split between the workers, but if any of the relevant vacuum parameters are set for the table currently being vacuumed, then that worker gets the full resources configured for that table, and everyone else divides up the amount that's configured globally. So if you went and set the cost delay and cost limit for all of your tables to exactly the same values that are configured globally, you'd vacuum 3 times faster than if you relied on the identical global defaults (or N times faster, where N is the value you've picked for autovacuum_max_workers). If you have one really big table that requires continuous vacuuming, you could slow down vacuuming on that table through manual configuration settings and still end up speeding up vacuuming overall, because the remaining workers would be dividing the budget implied by the default settings among N-1 workers instead of N workers. As far as I can see, none of this is documented, which is perhaps for the best, because IMV it makes no sense. I think we need to move more toward a model where VACUUM just keeps up. Emergency mode is a step in that direction, because the definition of an emergency is that we're definitely not keeping up, but I think we need something less Boolean. If the database gets bigger or smaller or more or less active, autovacuum should somehow just adjust to that, without so much manual fiddling. I think it's good to have the possibility of some manual fiddling to handle problematic situations, but you shouldn't have to do it just because you made a table bigger. --=20 Robert Haas EDB: http://www.enterprisedb.com