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 1pZJY9-0004h1-KP for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 22:43:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZJY7-00045p-CN for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 22:43:19 +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 1pZJY7-00045f-0u for pgsql-hackers@lists.postgresql.org; Mon, 06 Mar 2023 22:43:19 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pZJY3-0005X5-NA for pgsql-hackers@postgresql.org; Mon, 06 Mar 2023 22:43:18 +0000 Received: by mail-pl1-x636.google.com with SMTP id i5so12206835pla.2 for ; Mon, 06 Mar 2023 14:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678142593; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zThoM8Ldu8pRdm6QV6Uio4ZY7j+qJf+lkyN3I1Yl9E8=; b=n9TvCdy6ZhVpzFLQeO5rtoa24MkScsqPzXulr0PZqhSvQDcWOhaS8kNBfiAFhn7d0P 5NT4g8oK2kiVOzn00c+fyh3M2utdnJI8OZmZ6HRGNsxbZ3GjZmxuy4138k9xeHqrFySQ sATxap1HQcPz7I3/MCd+cBjFcoPQZEHNBLtn2mofzP4JkI/a08yBgzrypOYDvx4vnjmK uXtiN1Q3I8UFa7O7IG2HYDMEXyM7n8sSgRA/PwwP26v5AjR4A6wSVqI5nzNurPOFjZWg 0fXkiELtAZlgGFiN4HJdwS7aNTFFMfj32t9cbxMHFA2ahI/IuejbOpNueVyg0dcrrhD3 BGxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678142593; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zThoM8Ldu8pRdm6QV6Uio4ZY7j+qJf+lkyN3I1Yl9E8=; b=x31znCZtiCER8mF0jYgnO9dag+pucp4DtINLfChv+oQeMVHcDUidANPHfM+wDN4fCz 6yYLgV3rA9nxzBQi1aLS0YjEGohh37A25gwPXhpZY/OrdkDWsz0ehxLTQ6tvLLdy45zw lv4JOwsGehc+Ld+hsBrtNlbHz7hwZ0A/Rpd6bRYpOIJuTOwnqQLEJPzn78/izAao/vwu 6eoIuDIPGRqi9pjA8wn4ydPDu/Kj+F6TN/mdkiyNDCIQUvdbxMN0MRiP+sbsTVzhBEnx 1L+N33rhU3RZdFc5L8kIdeWpqOYOyGaRJwGT+Ruq0vac7R5obAXYBy5xajWgxdJhZrTv hkWw== X-Gm-Message-State: AO0yUKUs7/fuWNaDPkjBfotMasBEfv4zJNMHpVXuKWFZ6D4N5WZygsq1 1OwkvhOWXc8/XZvQFCRn0KPIjCc+QAY= X-Google-Smtp-Source: AK7set/VkaBUB9BHDXmyTpbPGWcay6T/+qzwE2p7F4XPQmyeo/QXyc7DUxOTw2JsaPMXaWvsIkN6kg== X-Received: by 2002:a17:902:e848:b0:19e:7f7f:c8b1 with SMTP id t8-20020a170902e84800b0019e7f7fc8b1mr14945771plg.51.1678142592967; Mon, 06 Mar 2023 14:43:12 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id le6-20020a170902fb0600b0019edd30f828sm271064plb.209.2023.03.06.14.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 14:43:12 -0800 (PST) Date: Mon, 6 Mar 2023 14:43:10 -0800 From: Nathan Bossart To: pgsql-hackers@postgresql.org, michael@paquier.xyz Subject: Re: add PROCESS_MAIN to VACUUM Message-ID: <20230306224310.GA3165453@nathanxps13> References: <20230301172637.GA1456203@nathanxps13> <20230302065359.GA2140777@nathanxps13> <20230306173723.GA2934573@nathanxps13> <20230306194009.5cn6sp3wjotd36nu@liskov> <20230306202734.GA3033389@nathanxps13> <20230306211337.GA3076909@nathanxps13> <20230306220958.rk4b4msmybi6hm56@liskov> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline In-Reply-To: <20230306220958.rk4b4msmybi6hm56@liskov> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 06, 2023 at 05:09:58PM -0500, Melanie Plageman wrote: > I would move this comment inside of the outer if statement since it is > distinguishing between the two branches of the inner if statement. Oops, done. > Also, I would still consider putting a comment above that reminds us that > VACOPT_PROCESS_MAIN is the default and will vacuum the main relation. I tried adding something along these lines. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --17pEHd4RhPHOinZp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="process_main_readability_fix_v2.patch" diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 580f966499..90a42e089c 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -2058,25 +2058,32 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs) save_nestlevel = NewGUCNestLevel(); /* - * Do the actual work --- either FULL or "lazy" vacuum + * If PROCESS_MAIN is set (the default), it's time to vacuum the main + * relation. Otherwise, we can skip this part. If required, we'll process + * the TOAST table later. */ - if ((params->options & VACOPT_FULL) && - (params->options & VACOPT_PROCESS_MAIN)) + if (params->options & VACOPT_PROCESS_MAIN) { - ClusterParams cluster_params = {0}; + /* + * Do the actual work --- either FULL or "lazy" vacuum + */ + if (params->options & VACOPT_FULL) + { + ClusterParams cluster_params = {0}; - /* close relation before vacuuming, but hold lock until commit */ - relation_close(rel, NoLock); - rel = NULL; + /* close relation before vacuuming, but hold lock until commit */ + relation_close(rel, NoLock); + rel = NULL; - if ((params->options & VACOPT_VERBOSE) != 0) - cluster_params.options |= CLUOPT_VERBOSE; + if ((params->options & VACOPT_VERBOSE) != 0) + cluster_params.options |= CLUOPT_VERBOSE; - /* VACUUM FULL is now a variant of CLUSTER; see cluster.c */ - cluster_rel(relid, InvalidOid, &cluster_params); + /* VACUUM FULL is now a variant of CLUSTER; see cluster.c */ + cluster_rel(relid, InvalidOid, &cluster_params); + } + else + table_relation_vacuum(rel, params, vac_strategy); } - else if (params->options & VACOPT_PROCESS_MAIN) - table_relation_vacuum(rel, params, vac_strategy); /* Roll back any GUC changes executed by index functions */ AtEOXact_GUC(false, save_nestlevel); --17pEHd4RhPHOinZp--