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 1w9Ryw-001RdK-0k for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 18:13:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9Ryu-0048Dd-2A for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 18:13:57 +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 1w9Ryt-0048DV-2Q for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2026 18:13:56 +0000 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w9Ryr-00000000iPB-3rXE for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2026 18:13:55 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id DF5C9EC00D4; Sun, 5 Apr 2026 14:13:52 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 05 Apr 2026 14:13:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=1775412832; x=1775499232; bh=+rxdd6yIGA odSe41gv+QhF0AWCz6frzYfCPMbeowUwA=; b=XeRAchpxq08oLhJ7mrtldUvQjB IXErMBNcuQIwBeECfV1Z0fUA6zXJ2aOac5MqdMWNR0tp/86yRkBnniHu/nZKIqEM O0l1sZ/YubpiUoeKrDwJKPgCWjvJRFGsfGJroWSKYhF/6od1g09cnQIoeBXfeTDM 83jf896LoyPgu7MqsZwaX80qWDkso7CxfIS/VVEuKi/VvYrc4CBzwbh+/XRfOh7K 5bfnz0zifdTYgyFL+vlXpbRhPT6RsKjqIxs3qNVsrSUE02Dpd/eUQvkZQS+GyExI pgflLlkOEk1np0G+5UDR//iQQWMhNud4qTjtrrXg6NIe/7V6G4UjgrfZJZcQ== 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= 1775412832; x=1775499232; bh=+rxdd6yIGAodSe41gv+QhF0AWCz6frzYfCP MbeowUwA=; b=GO9ySUH3iBVdn6zsgCqyBfNtMkumXXkH+yWN7BQMISMHPBI1Fg0 kOyHi1BsvtNB3P3l/Skk9RJu7xSvUC4IM37NHVgylWpOg3ui7xCaE92QtDyMSTlG ZCZTwoFVbClTxqZboV8dCvrpTM5XDFB5K9D9t1pckZwKDRxjF3NYNyqOHGqPXdye 6AjPrOels+h7EFOnF3JrCXEWQjjjnBkk5714MhgW5+mn8LJPC5cjLbUeG4R4IYrc wuXKHKjD9FEuVUey6SMimk4pUo9Yw4Y9ZLVd0g/dwL+lX73gHwJCz/zQ+hhlELDY kmvDDZ2/xTMp+fDaVHWyP8Eam/MFDAXXKKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduheegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdfstddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeffffgledvffegtdevlefgtdeggffhvdekgfegteeiveejkeetudelveejhfeu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepiedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtoheplhhukhgrshesfhhithhtlhdrtghomhdprhgtphhtth hopehsmhhithhhphgsvddvhedtsehgmhgrihhlrdgtohhmpdhrtghpthhtohephhhlihhn nhgrkhgrsehikhhirdhfihdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlih hsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopeiishholhhtrdhprghr rhgrghhisehpvghrtghonhgrrdgtohhmpdhrtghpthhtohepthhomhgrshesvhhonhgurh grrdhmvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 5 Apr 2026 14:13:52 -0400 (EDT) Date: Sun, 5 Apr 2026 14:13:51 -0400 From: Andres Freund To: Lukas Fittl Cc: Heikki Linnakangas , PostgreSQL Hackers , Zsolt Parragi , Tomas Vondra , Peter Smith Subject: Re: Stack-based tracking of per-node WAL/buffer usage Message-ID: References: <57biou6l65r7gr4nunoe6lignz2x6m3w45gihoypaez4pc46di@txj3bakhj66l> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Not a real reply to your email, just looking at committing 0001/0002 to get them out of the way. Unfortunately I think 0001 on its own doesn't actually work correctly. I luckily tried an EXPLAIN ANALYZE with triggers and noticed that the time is reported as zeroes. The only reason I tried is because I misread the diff and though you'd changed the calls=%.3f to calls=%d, even though the old state is calls=%.0f... The reason it doesn't work is that explain shows tginstr->instr.total, but with the patch the trigger instrumentation just computes tginstr->instr.{counter,firsttuple}. And of course we don't have any tests even showing trigger output. Not that such a test would have been likely to catch this issue, as something like the the amount of time is nontrivial to test. This is actually fixed by 0002, as it makes InstrStop() update ->total, rather than ->counter as before. But I'd prefer not to break the intermediary state ;). I guess we could squash both patches? But probably the least bad solution is to add an InstrEndLoop() to in 0001 and remove it again in 0002. Re 0002 In passing, drop the "n" argument to InstrAlloc, as all remaining callers need exactly one Instrumentation struct. I think that probably should be in 0001? I'm kinda wondering whether, to keep the line lenghts manageable, --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1837,7 +1837,7 @@ ExplainNode(PlanState *planstate, List *ancestors, { double nloops = planstate->instrument->nloops; double startup_ms = INSTR_TIME_GET_MILLISEC(planstate->instrument->startup) / nloops; - double total_ms = INSTR_TIME_GET_MILLISEC(planstate->instrument->total) / nloops; + double total_ms = INSTR_TIME_GET_MILLISEC(planstate->instrument->instr.total) / nloops; double rows = planstate->instrument->ntuples / nloops; Should store planstate->instrument in a local var and wrap after =. But not sure it's worth bothering with. Greetings, Andres Freund