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 1vgERP-009iLS-0r for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 03:54:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vgERN-00EYwf-0t for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 03:54:33 +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 1vgERM-00EYwU-39 for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 03:54:33 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vgERK-000Uxk-2N for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 03:54:32 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b8712507269so73647766b.3 for ; Wed, 14 Jan 2026 19:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1768449268; cv=none; d=google.com; s=arc-20240605; b=Q9i7jOS5xGxlAvhmTCoSNpiBhYp/QD3OCfGLanNtL6y6EA9uj5e6Swt/9nJJKhN8Tb ymmsMLvJ4Q3UOZSjGEKXPTVsOjv1xclTSXrWvqG4BLT8HGPK43SEYPwcURjp0rL0gJ37 nTd2ga4dYei4crxBXvHMnrf0ps2TnOA4DWD0Hb9R8fMvM8gWdJaHm7Ry60nqy395q3yZ xZW1XP+40g5FgPvxEvlt76I4Jup0YEF/cT45p5/AcEfPO+dfSkMfPJJNfLy6gfCGbKo5 BmFEK/llZxm0Z9q3hi6sAaMWb0NrldRoqd+w9jVdWGTHDhVE+Ny/AfkXI8/5oxCgyGJq NAaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=o47AIcsVn2r//hL0hEaZ5/dIygUmDDedGlMKEfQfoNY=; fh=PyrCF+qsNaqndkAt6nzpU6jTKSl/iqI3Radtv0tyAIM=; b=ZKZ+35Jo/6rMIP0ZTp3/36Pum0GI2xRU+r6t26CYJAR/UDEYzvB4p/K0wnIvMEja// 1176nnkZI5adJPWIkd8nEa/bfQoJagTj0hVSxKa9WBUtxRe7px1oqXUCxdpeTMj04yHM PXFNsHehOrSCk8p1eVEIMDOudsADRVxU3yb75mR+Z1ba8YTNStRZ96Iupz00zRhilI9e mdurdyKcYlzIFSZyxfgZ5n1W6Tv1cG50Scgv9kQwvCNVsFWr0Xre29yJAAu+kLlHkY95 JjofRx7XJ/QeXvAz3JoEmTxmUOAyDXIf3zSt2U9dipy3D5BsZ6Q0bDrN6077Pd5C5NpW lcFg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768449268; x=1769054068; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=o47AIcsVn2r//hL0hEaZ5/dIygUmDDedGlMKEfQfoNY=; b=hCtZI0ALkKY+UeYKS1Y2j/tKlN/6HtMVe1w1AiB5/4U9BhWEaHbxka/ZUxECQvxZk0 PFBeIQUcbrOZVy/MRKHz88DKz0F+XkHYhdGonenslAXim82XldiaiXSsNqINHD9l6nNn yd3snjY9bf7xwcijjV0T30p2gBnQPMV8VnYNtg8r/1eKMm7DDy+CFlVT7Fzp73xmgunW f/+eoapaEX1/uqe9AByD0ALzLmqH+3DdfMARfOn2WVeP2G40lUkce9OIXFegaZfPAaKh 5Mu+ugykxkg1mKdOIXJZuyECiFQkZqS8vkV6eFHNG4hnkUSTcBu075BdAUuIfYoBDFFy MF8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768449268; x=1769054068; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=o47AIcsVn2r//hL0hEaZ5/dIygUmDDedGlMKEfQfoNY=; b=l7PNlOMpWGvq5mXirugxyN+3IHZMBXNwrgwam5k7vIRVXpMjsySVz4d2gpJHnbU/1L 7YvU84QlnuBr00z4wIR6aBdrlgWAoMAtqVT9118h44LOoqnIqYO9lk/UiWfJamhjiPYY QzJEN97WW9I3Npmwh9asqJu6B0LT4qHwv4JSBSkTeu/UzTDaBFMaa39eTjPlbk0OWfYz YsxwudrTDWtSoKW4pxpX5ftggzrSf5UAKKDjqzzSoEWO50Vws8Yw7bvZAFVvuVlwsGSh ctWxW/qWyCPI9W1e8B1xCE+sl08aV2V5acjdOdIUv3QfN8mwL/v5nIXHZo+GIMG0qYjg LF6w== X-Gm-Message-State: AOJu0Yxw1+8kcREb0ibNzGYtmYqYDWZt1tYw5xg8wiMo8c1SPyIhS5gu PoXTm+5ANBBt23lYTsXAphY2ONVm92kKsq8z8UoQ01D7IhkuQ1JeY+lryhGUDhCcDXIpA+vMJK0 hcifB/qakWvY92XbeoCprfMml37AbR8rciv6ZEAQ= X-Gm-Gg: AY/fxX54VG0hTaKHL/Feo0B0SXKMju7Vdmr4DM/4oeiG6PPuF+KtCGyBIi0AD1vuw9K XvAf/2mEcpE/FnSaMataQy92R9p//UzRFomlsT4I2dGfpEH1aqiL1DonFw1+mSYqhC2WDxddv5L 5q6foGC/y5l2edX3tS/v4H5RwTNqj11upZnlPlLJG4ueXEg7wkQqGivXDjpz13NT2h+PDX/7HnP jiF8tiCGzKxOpmSYhfXK23N6P0Fh04zHay3w42QW8n/DuovtxaCnZkqy8G1eAU33q3qew== X-Received: by 2002:a17:906:6a08:b0:b73:8639:cd96 with SMTP id a640c23a62f3a-b87610b741amr391495766b.24.1768449268230; Wed, 14 Jan 2026 19:54:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Wed, 14 Jan 2026 21:54:17 -0600 X-Gm-Features: AZwV_QjfkPHIB4WBtvDT_zxerA4rB0wiVMhmIngbTi9dJHWRrfxBmCEE6siawsQ Message-ID: Subject: Re: Flush some statistics within running transactions To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Thanks for these patches! I took a quick look at the patches and I have some general comments. > Long running transactions can accumulate significant statistics (WAL, IO,= ...) > that remain unflushed until the transaction ends. This delays visibility = of > resource usage in monitoring views like pg_stat_io and pg_stat_wal. +1. I do think this is a good idea. Long-running transactions cause accumul= ated stats to appear as spikes in monitoring tools rather than as gradual activi= ty. This would help level out, though not eliminate, those artificial spikes. > The 1 second flush interval is currently hardcoded but we could imagine i= ncrease > it or make it configurable. Someone may want to turn this off as well. I think a GUC will be needed. > RELATION stats are making use of FLUSH_MIXED: > stats: numscans, tuples_returned, tuples_fetched, blocks_fetched, > blocks_hit I=E2=80=99m concerned that fields being temporarily out of sync might impac= t monitoring calculations, if the formula is dealing with fields that have different flush strategies. That said, minor discrepancies are usually tolerable for monitoring data analysis. For the numscans, should we not also update the scan timestamp? -- Sami Imseih Amazon Web Services (AWS)