Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vuhf4-002G6j-0F for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 01:56:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vuhf0-00GMCh-2M for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 01:56:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vuhez-00GMCZ-2v for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 01:56:26 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vuhew-00000000t2V-2bjW for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 01:56:24 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 765E3EC0550; Mon, 23 Feb 2026 20:56:22 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Mon, 23 Feb 2026 20:56:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1771898182; x=1771984582; bh=3mB7kTRC2F 81wxGNX/W6rSxjnh8ji20+ipMC1fIIsOI=; b=OBdy4Hdtf45XNqBuxKM/n2hMGZ K0h6L0t5YWCvLngd2rXb8QUPCllWdMcWyn4FV4Z5XDE27XAEsY8XkkjrY4vCokmP L+blkU+yPnSmD1ZaEnrvmzHoaYJ/NjmClwPPWnS6bhohJTHy2LjwH/tBeqpi+z0W HtUL9uv8dFJVSf7JeSsTMC+3fuH6aBQ9bQmJvTooGCpSlSaovWuf68hco9zKLd3U bnFyjFkyYc5tvy8Vcmb6PVtqvkulRooApsjpW3m2fV868SiU9bvUEL1G7e/yiZOV c4vFaPNDZerGQUh5XbW96D9JjHZ6SN6sBozw76NGduiMdeSRPE6C+QjO19tA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1771898182; x=1771984582; bh=3mB7kTRC2F81wxGNX/W6rSxjnh8ji20+ipM C1fIIsOI=; b=L5upv5AiNDJ/pVnu9wO0pduGVIJ2H81ckMuu+wzDbCbRIU6kQ3L 2/90SCF1Y9hoyUL+13UGPf8sAr6meaEiwWKoSIhf372XJuPs0cSyP4up6j47myw6 dgE6MWjEAXxoAiqkLpqe1xhcrrqQEYr243v4dcHIz9f4QkCFkgSDp2DlZSSZHdsT oGuQThdJAUSFjzvaihKYAKQZOC091ztkcFMsnsW/kIM9dfR2WOhj2QfdsznZfUCA dFT5RADPbolcDdbK323xMfHaZNkqtRa4pwOTqhGW/V/v5zWN/qfvvrQa0yFT1yUE yqbAXYjO6xL8Km5TxRRTeKiU6NRrom+mwBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvfeekkeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgrmh himhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthhopegsvghrthhrrghnuggurhho uhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehmrghsrghordhfuhhjih hisehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepiihsohhlthdrphgrrh hrrghgihesphgvrhgtohhnrgdrtghomh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Feb 2026 20:56:20 -0500 (EST) Date: Tue, 24 Feb 2026 10:56:16 +0900 From: Michael Paquier To: Sami Imseih Cc: Bertrand Drouvot , Fujii Masao , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Subject: Re: Flush some statistics within running transactions Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="L0uppPPSVDe0YyGT" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --L0uppPPSVDe0YyGT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 23, 2026 at 05:47:22PM -0600, Sami Imseih wrote: >> I think the logic for fixed stats and variable stats should be the same.= If >> not we could observe discrepancies: for example a long running select co= uld >> genereate reads/hits IO visible in pg_stat_io but tuples_returned, tuple= s_fetched, >> blocks_fetched or blocks_hit would not be updated until the session goes= idle. >=20 > After having more time to think about this, I believe it can be much simp= ler. > As soon as we enter an idle-in-transaction (aborted) state, we can simply > schedule an anytime update. This ensures that a flush is scheduled whenev= er > the fixed stats trigger one, which will likely be the most common reason > (e.g., I/O stats, WAL stats, etc.). To cover the cases where fixed stats > do not schedule a flush, we can also schedule one as soon as a transaction > goes idle. >=20 > In my mind, this makes this whole flushing scheduling behavior easy to re= ason > about, and if we introduce future anytime stats anywhere, we are not requ= ired > to schedule a flush for each individual field. The flush callback will of= course > still need to decide what to flush anytime or at the transaction boundary. >=20 > What do you think? I cannot picture yet fully how a patch among these lines would be shaped, but having a strategic flush of the stats when we are in an idle-in-transaction state sounds like an interesting option here. I think that this leans towards two first pieces of infrastructure for this patch set: - The new stats kind option. - A new pgstats API that is able to classify the flushes depending on property assigned for each stats kind, and make these happen on a caller-basis. -- Michael --L0uppPPSVDe0YyGT Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmdBUAACgkQnvQgOdby QH0Ueg/8DTwv4//tT/CFKh5PSgsTsgLBKc6JMVdm1bA+ITYPyjkNQw4AtlzpvfS0 JwqVbmPWH+9GkIhFo65TwyDGop2nMDG67+dXIDGMuvOpjC9HSWWSxNoFZ5x4R4FR A9t/yidwwToq3xDdDV1Gw3lYybES+Y68rOmRgAZGU2un6BKMPmbL7AC+1u2vbPqu 7+3aaDbY4BNskscpZJA7WpIFuDqBGd+4rlSX98x3U0WdjEIr28WU9AAb319xrDyH +S7X18T/Sq5Qp1UAHP+rDjExULTYKi5BTlpZw1JJq6kn95cGdh8THwqzg/Aaiekn 3wTiibGhhP9HydCaIhYrOlwQdUm3dD92Fls6KEzv3W45muUiglyh0nL/dLhriy0W h8k15+OsJVWAFsCKzETfWY52TNT1sFCExiQQJlR4GtE+EczWqAgV6mUBexTauLoo YEc9xbc6X3Wmr+yOON8Qdhinb/bIXDThTsBikCKwcIUjHBTafOR0oha1xUsPB5L8 JnHxtAn+7HJ3vg3K/VnwGYWrU1DmLcjCdTPqqiqGvhZClJzVOWVQk7pI9R1Fvwls LVNN2t1JXI/28bb2OtTKCeBKXtjygRoMg+HMnS6/XVnTCWIncHovv5Aw+91TKf65 CCO5748NRxxUS1OSwJGjJvJFhhydWBGoVLdE5oo5Eu0cGIWcMns= =RyFO -----END PGP SIGNATURE----- --L0uppPPSVDe0YyGT--