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 1pAjCr-0002Ee-LK for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Dec 2022 03:03:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pAjCp-000830-DW for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Dec 2022 03:03:43 +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 1pAjCn-00082q-C6 for pgsql-hackers@lists.postgresql.org; Thu, 29 Dec 2022 03:03:43 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pAjCh-0005vh-JH for pgsql-hackers@lists.postgresql.org; Thu, 29 Dec 2022 03:03:40 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3F0B85C00E1; Wed, 28 Dec 2022 22:03:32 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 28 Dec 2022 22:03:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1672283012; x=1672369412; bh=VE6XrLsfxi zJqF3k72Kg2l2D2+xBCl+UcbmUzv4jEho=; b=zvG0xbhXGaiXb2WOkOrzVP2/oX H26NKLV7RqmJWGHDSAcOjxCQ89TabX5YtEX8QF+zHffdVYmhWCjajoI0BdKSx5Mn AVZ5vwET5rPzn6AbDEE0JKYsq9FNJAhQTXXuig4KPesSVL48N0QXIv4N5p4OwBXM zOARYzPQpyI8GxKALBr2zKLOIrB9Hf0jUpgzT+elA8jr8fQ4Vx7ptqcZf1Kzwz9q junTfuoqYHhxuwcC62YYpn9Wji6LKFXJyrfV72PPkvnofmdpXdLVJnoy9wpuC/gt A06Dq3ugm2HFtSEXruUyyV3L28rTI6l89vvCJyceyEQVIef2LAy1V8Ahq5Ig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1672283012; x=1672369412; bh=VE6XrLsfxizJqF3k72Kg2l2D2+xB Cl+UcbmUzv4jEho=; b=sMcK6OXScWMstog/Pr61dlqfey85OaAetoCAl65VVaIc 7zAnojCT7Yje89623UI7Yq9r6YM77DByZD0Pl78LoapDYw6vY7Egl1alsPtqUnry QhkNIVLmwJtsDNhQ2iuyuL1QuqHkFCqwM5GdqJUV67+0Oc2SBVDhr41v6SgKVMBd +oVJCWT7n8bxI8sFzDcSIv6CwYS6vIajL/Ed4wIeSJKWNVH9zeA5w/+GlWLJ/aT5 oD3phgflETM09c+afMeU3O38PN+BhvcHCQSd5Jq0TYexFxhe8YccKIK6naRhlhSd X1wG6cVYCKlAwuk7hBUHQx2kk+a79GPsNqJ8DN20wA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieefgdehhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 22:03:31 -0500 (EST) Date: Wed, 28 Dec 2022 19:03:29 -0800 From: Andres Freund To: Tom Lane Cc: Peter Geoghegan , postgresql@taljaren.se, pgsql-hackers@lists.postgresql.org, Michael Paquier Subject: Re: BUG #17717: Regression in vacuumdb (15 is slower than 10/11 and possible memory issue) Message-ID: <20221229030329.fbpiitatmowzza6c@awork3.anarazel.de> References: <17717-6c50eb1c7d23a886@postgresql.org> <3439037.1671130590@sss.pgh.pa.us> <3544447.1671141436@sss.pgh.pa.us> <3672943.1671202149@sss.pgh.pa.us> <407579.1672258403@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <407579.1672258403@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-12-28 15:13:23 -0500, Tom Lane wrote: > [ redirecting to -hackers because patch attached ] > > Peter Geoghegan writes: > > On Fri, Dec 16, 2022 at 6:49 AM Tom Lane wrote: > >> That is a really good point. How about teaching VACUUM to track > >> the oldest original relfrozenxid and relminmxid among the table(s) > >> it processed, and skip vac_update_datfrozenxid unless at least one > >> of those matches the database's values? For extra credit, also > >> skip if we didn't successfully advance the source rel's value. > > > Hmm. I think that that would probably work. > > I poked into that idea some more and concluded that getting VACUUM to > manage it behind the user's back is not going to work very reliably. > The key problem is explained by this existing comment in autovacuum.c: > > * Even if we didn't vacuum anything, it may still be important to do > * this, because one indirect effect of vac_update_datfrozenxid() is to > * update ShmemVariableCache->xidVacLimit. That might need to be done > * even if we haven't vacuumed anything, because relations with older > * relfrozenxid values or other databases with older datfrozenxid values > * might have been dropped, allowing xidVacLimit to advance. > > That is, if the table that's holding back datfrozenxid gets dropped > between VACUUM runs, VACUUM would never think that it might have > advanced the global minimum. I wonder if a less aggressive version of this idea might still work. Perhaps we could use ShmemVariableCache->latestCompletedXid or ShmemVariableCache->nextXid to skip at least some updates? Obviously this isn't going to help if there's a lot of concurrent activity, but the case of just running vacuumdb -a might be substantially improved. Separately I wonder if it's worth micro-optimizing vac_update_datfrozenxid() a bit. I e.g. see a noticable speedup bypassing systable_getnext() and using heap_getnext(). It's really too bad that we want to check for "in the future" xids, otherwise we could use a ScanKey to filter at a lower level. Greetings, Andres Freund