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 1pZIAP-0007jg-P2 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 21:14:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZI9Q-0001WT-2g for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 21:13:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZI9P-0001WK-N9 for pgsql-hackers@lists.postgresql.org; Mon, 06 Mar 2023 21:13:43 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pZI9M-0004Ts-UD for pgsql-hackers@postgresql.org; Mon, 06 Mar 2023 21:13:42 +0000 Received: by mail-pj1-x102f.google.com with SMTP id p3-20020a17090ad30300b0023a1cd5065fso10002126pju.0 for ; Mon, 06 Mar 2023 13:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678137220; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=jucEphkiOaJobwHWrTG8GkKFBo6sYQ+AcKx7WonQoEw=; b=BeeIwiooxbG6vgmLrHFI8c7/pQ6RvT8MEbq8C9i9vrhgekCb5Cu1GSsbXg4IzpqUFb 6FGNL31DuKUknbiX8Rlvih+n3cIxEf+qD+HccwKgxZqVGYqVjo1XH2aUYtAP8Oto2PBs QltGf5OHgs08bKhf2jE2HTpifkpiERuxjsZBxbwcYODB5DEyXGrx17wJw+p0kdFle6mz ecInGDRl0cfZjaS7WWYGGH0qrZshtPTy4hZdwXHwDJVX0Ht8YYc8T8QBdp/bheYEdYql hCIWJj2WeozCOSQJcUK9Wlhka2dpKPc6y8mk9LASYhKVGv9HvoRDU5ocgDTt13C/CXMJ g1Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678137220; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jucEphkiOaJobwHWrTG8GkKFBo6sYQ+AcKx7WonQoEw=; b=rqT5KNpmWsnjJrBp0uF1A2rMQ2q4kVTqeaICpP51ZvECIpKN9dbEGngyHzxD5fbcxG CSEcKApFWdJ4CDoX6v7KE7MDoj1dAWc5bD6kRkA8uUaQsD5AAzDK6teOY7mKRWCuF3TG IIJiJrSdlBwfD+nas2F0CfvQHGSDqD+aVEAmZNcI6rNzGh7OUQrKo9Nile1i2SujdcG5 EQss9S6QXU6AS9SlhLtXRcsU2MIlgMSC0/FO07xWg2QfUXu6FTqoA7eC99j8ghxD5sIN Taada6sKLIYejBrfIfSWYqzz+XfcI5L9uGaAlHwu9tDlpyXeMAzuOMzUi5bWk7Jkycst l5bQ== X-Gm-Message-State: AO0yUKWurb44Ayc3tQIN3nlviD3JwBZ79Ti7P6KDOn4JHzS1KJmbLb7d Gw9aITWdql8fEspr9qqV5Ao= X-Google-Smtp-Source: AK7set9uJAxV20tAjWsfx0TAAP6cwd7nkHnAQu7p1Ea4k0WwbQORxHujOYug5KgiC7vMdL4J9gMWaA== X-Received: by 2002:a17:903:11c8:b0:199:2a89:f912 with SMTP id q8-20020a17090311c800b001992a89f912mr14331558plh.20.1678137219880; Mon, 06 Mar 2023 13:13:39 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id jh5-20020a170903328500b0019a983f0119sm7120000plb.307.2023.03.06.13.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 13:13:39 -0800 (PST) Date: Mon, 6 Mar 2023 13:13:37 -0800 From: Nathan Bossart To: Melanie Plageman Cc: Michael Paquier , vignesh C , pgsql-hackers@postgresql.org Subject: Re: add PROCESS_MAIN to VACUUM Message-ID: <20230306211337.GA3076909@nathanxps13> References: <20230119190807.GA4062411@nathanxps13> <20230301172637.GA1456203@nathanxps13> <20230302065359.GA2140777@nathanxps13> <20230306173723.GA2934573@nathanxps13> <20230306194009.5cn6sp3wjotd36nu@liskov> <20230306202734.GA3033389@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="liOOAslEiF7prFVr" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --liOOAslEiF7prFVr Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Mar 06, 2023 at 03:48:28PM -0500, Melanie Plageman wrote: > On Mon, Mar 6, 2023 at 3:27 PM Nathan Bossart wrote: >> On Mon, Mar 06, 2023 at 02:40:09PM -0500, Melanie Plageman wrote: >> > I noticed in vacuum_rel() in vacuum.c where table_relation_vacuum() is >> > called, 4211fbd84 changes the else into an else if [1]. I understand >> > after reading the commit and re-reading the code why that is now, but I >> > was initially confused. I was thinking it might be nice to have a >> > comment mentioning why there is no else case here (i.e. that the main >> > table relation will be vacuumed on the else if branch). >> >> This was a hack to avoid another level of indentation for that whole block >> of code, but based on your comment, it might be better to just surround >> this entire section with an "if (params->options & VACOPT_PROCESS_MAIN)" >> check. WDYT? > > I think that would be clearer. Here's a patch. Thanks for reviewing. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --liOOAslEiF7prFVr Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="process_main_readability_fix.patch" diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 580f966499..fb1ef28fa9 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -2060,23 +2060,25 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, bool skip_privs) /* * Do the actual work --- either FULL or "lazy" vacuum */ - if ((params->options & VACOPT_FULL) && - (params->options & VACOPT_PROCESS_MAIN)) + if (params->options & VACOPT_PROCESS_MAIN) { - ClusterParams cluster_params = {0}; + 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); --liOOAslEiF7prFVr--