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 1n9p91-0003QF-I2 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 14:07: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 1n9p8z-0002u5-Jf for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 14:07: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 1n9p8z-0002tv-AW for pgsql-hackers@lists.postgresql.org; Tue, 18 Jan 2022 14:07:29 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n9p8v-0006qo-RQ for pgsql-hackers@postgresql.org; Tue, 18 Jan 2022 14:07:28 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 44C5B3200946; Tue, 18 Jan 2022 09:07:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 18 Jan 2022 09:07:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=KmlyBhZHlyPW6yLCHXgvzdSYAHzYqzH/+I49VJ+/4KU=; b=IEBdsF8K 2g5ZHIWKuYFNnVjKAyNDQVOw3GQHnwozK4Js4e5wSBclcdGacug42H2EWTXiuZoK vV3NVfVRTjzFAfrDt93dLHcICJE2TdpQqwcna0PNio1q46quqhWcLiIKkbtmERqw ZB1cvmKBHDVQ7mjdYOiGMG2AM079MWf8GNb46EdbdIo39Ea2Y2IA36z95LqNjqX6 Q0l86AjR+yr1VO4wMegPIlwXsALpKbk9jr9I4NXh2iszi2Dq1rtE/ny+T59M0VvB gcFThAHL1FbUsdTNGlGD3JbWUF4USYTM9j/z+0/ECWhdkYnKEAl+cqhLGgCACKhO rdhi06kzWtcddg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepudejveejffejveduudetvdekieeuiedtvdeileefkeevjedu feeguedvjefhueelnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Jan 2022 09:07:21 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4BD9C2A07D6; Tue, 18 Jan 2022 11:07:19 -0300 (-03) Date: Tue, 18 Jan 2022 11:07:19 -0300 From: Alvaro Herrera To: Robert Haas Cc: James Coleman , pgsql-hackers Subject: Re: Add last commit LSN to pg_last_committed_xact() Message-ID: <202201181407.gpu6ivyddgkw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 On 2022-Jan-17, Robert Haas wrote: > On Mon, Jan 17, 2022 at 4:34 PM Alvaro Herrera wrote: > > Maybe it would work to have a single LSN in shared memory, as an atomic > > variable, which uses monotonic advance[1] to be updated. Whether this is > > updated or not would depend on a new GUC, maybe track_latest_commit_lsn. > > Causing performance pain during transaction commit is not great, but at > > least this way it shouldn't be *too* a large hit. > > I don't know if it would or not, but it's such a hot path that I find > the idea a bit worrisome. Atomics aren't free - especially inside of a > loop. I think the aspect to worry about the most is what happens when the feature is disabled. The cost for that should be just one comparison, which I think can be optimized by the compiler fairly well. That should be cheap enough. People who enable it would have to pay the cost of the atomics, which is of course much higher. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/