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 1vii9Y-00DeGE-2O for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 00:02:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vii9X-009tN0-1c for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 00:02:23 +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 1vii9W-009tMs-18 for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 00:02:23 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vii9T-001fzU-2t for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 00:02:21 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 45BB67A006B; Wed, 21 Jan 2026 19:02:19 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 21 Jan 2026 19:02:19 -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=fm2; t=1769040139; x=1769126539; bh=K0P36doI3F mNTpgrjn9vTP4qFiWAlpWILJXi/QiMTyc=; b=RvAD8oJ0CxvZoQAXgNGQs1g2yi JZCN/Icx3WyeCTJVSeZQGRQ+v2GgbTNrLzxORatkgAqkwuD0a+EARkJ/RSLGeU9k cZ+1GKMdJz4gJiQxf5KJsygM7HQkdYTfuZF30e9kfKyCdKL7HGZaNkNrrOfo49Xn w2cpr50jplqc5bIu70IDyKEBEfgj1mUTQMZPvDIvx2nZpr7g+vBd2T6woeQkdgts ib474jOervknuXcgm8MmuVEE/klF08z7bQ2ejLpAPlwBeo40UYaWb/GjoWFvJytn 5jT8dNrXRUmIr8QCeTtwSH4Qg7fu/PlxVVS6/5YCFt1zXZrN+fK2qO1zo/Qw== 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=fm2; t= 1769040139; x=1769126539; bh=K0P36doI3FmNTpgrjn9vTP4qFiWAlpWILJX i/QiMTyc=; b=AQhjo2cZE+zt5DV3VFUooAkDiFeeLCmrjtyT05o2hSd+a8FCUsR PBFDdemlzdVYLtzrrZO16u6KyQbvhV4LevJVAyaDrnggMX9oYjxO7kdMrJqcmWGX YLyemeF/b5OLKcAwg95+j+m+JP9kIayL5TmK5re3a0reDzOI6MVyKZnKvnPYTRa/ /SaJ/HkntbmosUUhszz4QpHQAxcFlF9venU1RzHDWzloiNnyRVb9obk9MBxKasTM xKTUJdqlLFPKBYdgJK8ojOJ2T/pXNO48JdEbqpPONkmo4yiZQNeOxQ2Uop/yIz/P 4rNSpnFLcrYGz9aKgkTFV+rc27oc+BQv5xw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeegieejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsggvrh htrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgr mhhimhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkh gvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopeiishho lhhtrdhprghrrhgrghhisehpvghrtghonhgrrdgtohhm X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Jan 2026 19:02:16 -0500 (EST) Date: Thu, 22 Jan 2026 09:02:10 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Sami Imseih , 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="rtp21q2nnA9wQW1C" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rtp21q2nnA9wQW1C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 21, 2026 at 10:34:09AM +0000, Bertrand Drouvot wrote: > No, 0003 also changes the flush mode for the database KIND. All the field= s that > I mentioned are inherited from relations stats and are flushed only at tr= ansaction > boundaries (so they don't appear in pg_stat_database until the transaction > finishes). Does that make sense? (if the database kind is not switched to= =20 > flush any time then none would appear while the transaction is in progres= s, even > the ones inherited from relations stats). >=20 > PFA v3, also taking care of Zsolt's comment (thanks!) done up-thread. While reading through 0001, I got to question on which properties and/or assumptions of a stats kind one has to rely on to decide to what flush_mode should be set. To put is simpler, why don't we just do a periodic pgstat_report_stat(false) call that would flush all the stats for all stats kinds based on the new timeout registered, expanding a bit the flush we currently do when idle in ProcessInterrupts()? It seems that one point of contention should be=20 that we should be careful with entries in the shmem hash table that have been created in a transactional way, but we may already flush them while we are in a transaction state, no? Are there any fields in a stats kind that we do may not want to flush? If yes, it sounds to me that it would be better to document these in the structures to explain the reason why a flush mode is chosen over the other. I am also not convinced that we have to be that aggressive with these extra flushes. The target is long-running analytical queries, that could take minutes or even hours. Using the same value as PGSTAT_IDLE_INTERVAL (10s), perhaps renaming the value while on it, would be a more natural fit. A 1s vs 10s report interval does not really matter for long analytical queries, where I'd imagine data being picked up on at least a 30s interval, at the shortest. Of course, one may want to get a more "live" representation of the data with more aggressive flushes, but is that really helpful for long-running queries to have more granularity, stressing more the shmem state? -- Michael --rtp21q2nnA9wQW1C Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlxaQIACgkQnvQgOdby QH0BPg//TgRtxKmxmpegUo55m8MpgBhU9Rwq/eBfZcAS/wRaB4b/daYFS0riBUrg K+Sj1CJ3k6HvaEB+hyQx2DG9lMWE8LrONFMofOZyL5PtNqa/wMOoEGgVqsVkk/B4 1dufGhpwpI29N9WjCeQOcnarmYv8aNuQc+1lkVnSAxG5w77ScFpEO2ifATWZahpv LB1OrLeuvBqhY4hnC6GW1Ws1Kz8sqC0hdK9KLSkTtJ/qcn0jGeY1M6tasSRZpPqI sCQbQUZEqZgUE9/8ZQWAahF1Qa7WCDDnfmK3khDnTQSB9D3FCElv7zsFc3TLqnAu NcjshIFwgzLsYONkIAkj3yEUPfkcrruzsuqOPjE3A+DYpnypmZhyFnpLhdxg2SFv yqAu9155szzZ0QDgPNgX/5n/2lxVnRfCxCnmd8Y6K6ETrCKgJn6mREXhJoJH3yHp O2aM1rftn1BgymVg4hPeJiRBrkIUpLFhLp/rysNkAzXSy4j8J93at46F+KEgiGRM D01niQI7bSth6inpv84TP+tVwzDcpIXvB9A2EE8b2OBBpCxOZxk9VuY8oHUpG20Q CqzpRviHQbHRlk1j1PU5V8QQpSGGaRi2TQvGhQJIEcz60esCbHDq5JUMgN4mnQWW tPLrSdw5821AzeruHb5BEh07OR8lZaAy+qP1f3+J+ntKUpG72Bg= =JxQo -----END PGP SIGNATURE----- --rtp21q2nnA9wQW1C--