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 1vijhk-00EBE9-0m for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 01:41:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vijhi-00AEYU-1D for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 01:41:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vijhi-00AEYM-06 for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 01:41:46 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vijhg-001oou-1M for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 01:41:46 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-6505d141d02so661916a12.3 for ; Wed, 21 Jan 2026 17:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769046103; cv=none; d=google.com; s=arc-20240605; b=exNzgC6wxwMnJadckO/qbLJXGnjGUeus4LlxFryCoWI4AqlajnEf784zoVT0lnWAJO wzS7xybEZA7G9It+sR8ObONjnoOAAoNzMWDAIjKpJmoQawiq921HPOvLwJ9S0CEudci3 O+c0LiOBg1N/cakBkAzOenJiVXgpWvgdLLiby394CE3xAxjxf+SGDpxjxyrEgVT91UnR IUR/xLvPwYJn8oFqLIXm3dOPdGxTRz7shA0tUKtU/aTJqExCqsNWF38DuYMeSMT6Kqk3 BA/QrfxjHlefypPQttRX9e9b4utaSzlBt1zYhvfi+OKmqT93rH9qWA6oWPFADil+tfDV 5+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=ZlaSCMR+HrnkJtU5BfPfogt/Ym2GcbN4xMB3SiiFA1Q=; fh=wPHB6DK28hyIGKCdti92jOCAyFgJBkQQ++P6pvBfCSg=; b=bSSNg7R58MPeP2UJ4dQe2D68VMq6IJH1AbIwi/tXb2g/bqLfWjj8sYXS/tfWmJ7HbH auXHQgSSr5jBq3HkPLILDpBRb0SpYhBg8f02SEUKBEtCKXP8NFxJhrQrNGugAT26cpJx s3AUmoyiWQoiO980jlzZBAAFljAUWU7issjWfFz9TT1eIglojQcRrecRfULldRbRvQEm zrdgk9I73Y8aZTp8KMfTY8PMXgJAh0T5Py8x4iPCLyupcI+68dcoXTQxm+geKSP3fP+r nZTo8bdnUmztGohaiwOyFTOLmpGypZzjF4Qx2G2P1Egs5x6OJAaSC/tL4APjxrPc0z/8 zeMQ==; 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=1769046103; x=1769650903; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZlaSCMR+HrnkJtU5BfPfogt/Ym2GcbN4xMB3SiiFA1Q=; b=IkBsf2qtVg5xLbuMrnryq+dnRN1ZvCOnpZIuhFlK71x4/wLYX5ujmmVqOGuKJ+3Xs0 BXBdcifxlcn+imzFFEzrGtsrI2Zky6sqU/RtBbqPBS3YKT8O28ij5Ig+GSQU08o2lvlS uEeLCTEl+LuONtqzyzsBB3SOddRz7Cp4ScMnrdPK2nM1LYrbij4bpVNIBi7qXQo+Em0h vXcWvUi/xdt16y+AigtFKRnu3fbypmTXIu7LRzIiMuOiNQc95aWX1PBREMdB5OIwfQJL 54qoyErtXfC9RzDg0QbtPGVWZqt6QYDqGV/VBmXBVoXmxF5vh3DgOKDQSbmJkBfg/yxr 1xAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769046103; x=1769650903; h=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=ZlaSCMR+HrnkJtU5BfPfogt/Ym2GcbN4xMB3SiiFA1Q=; b=Kh+9Yzi5mLURvlhHjFsAS64B/8+XcZDPPb7KxkWDIxui62hUmw5mLCHDZQ7qJ3VM5j kUkUzhCqNY+3Sx+1WeZtLzJOhLYT7+eHDuc9ASnMzceJN+R7kwnd/HhDOTsOIQJ+ydk9 vdGUbrI0+s8pY5FORsjaAckK97emm8eQtjXRlubODOJTPzq2LlNQn6TCzonU9qyXF72A kwFkX78psUjRfgPBjkZ7WnohJYJK3SHurO/HdEjZ+suNIVfv7WVH0CqyGL6l48jLcLyP 2QDXJQlHe8wnKT7kC/oVCrkLqXTKYZjGtKFhvDRFRbuCN+2orq3C+IcEzk+3ymujOzek 1ZhQ== X-Forwarded-Encrypted: i=1; AJvYcCX04D1DoZ5P7B1edThAQVK6XpKrTSlBBz/MUuRVleFkfDKQVoTK4GMBnpCY+oDzKUCAivTt4nzd6J9bJCu0@lists.postgresql.org X-Gm-Message-State: AOJu0YzTeRAha7ydNHEX1aE3TV0M4mSgx+5cihjI/ZYx2HPJlGGaoM5Z zukUFNXjK8IWdmYRENCVWQd4iE73LBOjTSGGTZ1eT8e/+rJrb96hvSxgZuY4QoNMCLZNIJ82fv3 HQcgmD48FqiDQeBRW5aZRjg5pQYXheIY= X-Gm-Gg: AZuq6aKDRHLlyzYYro3zrjhoapBgTq2cg4qs0gOT4TvAwlNE4v5cdKBKug1z9jsR5Av BTc92w72KjmgbiDwai8TFOyRMhSai6Bv1pl6NKUa9xXI9jHU3f6Gf2G2pk7H9YLuwsmjkBLPtTk 2FV72wBIQP92Br0dyOUdSLCsvEj1TBmbEcJ5Z4wkqDRdeIVpMxjXgxLDpEprvuln9GUUKvQvvgU HUSmOhNjjIwVr8OwSDFGZwy0DEL5uVXOnr4vJ8iH1lkkfoGO39rZ1sdONZO7V/muLh23W8= X-Received: by 2002:a05:6402:50d4:b0:658:3838:282 with SMTP id 4fb4d7f45d1cf-6583838083dmr247866a12.22.1769046102784; Wed, 21 Jan 2026 17:41:42 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sami Imseih Date: Wed, 21 Jan 2026 19:41:30 -0600 X-Gm-Features: AZwV_Qh2W9k-MICX36-9dm_JLDoKIP9nJnYZwizjpqU0JikJnNCs5TOtLwjy2TA Message-ID: Subject: Re: Flush some statistics within running transactions To: Michael Paquier Cc: Bertrand Drouvot , pgsql-hackers@lists.postgresql.org, Zsolt Parragi Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > No, 0003 also changes the flush mode for the database KIND. All the fields that > > I mentioned are inherited from relations stats and are flushed only at transaction > > 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 > > flush any time then none would appear while the transaction is in progress, even > > the ones inherited from relations stats). > > > > 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()? There are some important cases in which we would want to distinguish between a "transaction boundary" flush vs an "anytime" flush. For example, xact_commit/rollback. I would want those fields to be in sync with tuples_inserted/updated/deleted to allow for accurate calculations like number of inserts per commit, etc. Another one would be n_mod_since_analyze, That should only be updated after commit (or not after rollback). Otherwise, it may throw autovanalyze threshold calculations way off. Same for n_dead_tup and autovacuum. > 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), PGSTAT_IDLE_INTERVAL is flushing an idle backend every 10 seconds IIUC. So this value only applies when outside of a transaction. > A 1s vs 10s report interval does not really matter for long analytical queries. Sure, Bertrand mentioned early in the thread that the anytime flushes could be made configurable. Perhaps that is a good idea where we can default with something large like 10s intervals for anytime flushes, but allow the user to configure a more frequent flushes ( although I would think that 1 sec is the minimum we should allow ). -- Sami Imseih Amazon Web Services (AWS)