v18-0016-WIP-instrumentation-Account-for-resource-usage-u.patch

application/octet-stream

Filename: v18-0016-WIP-instrumentation-Account-for-resource-usage-u.patch
Type: application/octet-stream
Part: 1
Message: Re: index prefetching

Patch

Format: format-patch
Series: patch v18-0016
Subject: WIP: instrumentation: Account for resource usage uring rescans
File+
src/backend/executor/execAmi.c 17 2
From 44475e6208ddb5d03e0c692efd3ef88f8cbcfa2e Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Thu, 19 Mar 2026 23:08:29 -0400
Subject: [PATCH v18 16/19] WIP: instrumentation: Account for resource usage
 uring rescans

Author:
Reviewed-by:
Discussion: https://postgr.es/m/
Backpatch:
---
 src/backend/executor/execAmi.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 979a852fe..03939521b 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -77,9 +77,15 @@ static bool IndexSupportsBackwardScan(Oid indexid);
 void
 ExecReScan(PlanState *node)
 {
-	/* If collecting timing stats, update them */
 	if (node->instrument)
-		InstrEndLoop(node->instrument);
+	{
+		/*
+		 * Rescan in some node types can take long enough to be worth
+		 * accounting for.
+		 */
+		if (node->instrument->running)
+			InstrStartNode(node->instrument);
+	}
 
 	/*
 	 * If we have changed parameters, propagate that info.
@@ -309,6 +315,15 @@ ExecReScan(PlanState *node)
 		bms_free(node->chgParam);
 		node->chgParam = NULL;
 	}
+
+	if (node->instrument)
+	{
+		if (node->instrument->running)
+			InstrStopNode(node->instrument, 0);
+
+		/* If collecting timing stats, update them */
+		InstrEndLoop(node->instrument);
+	}
 }
 
 /*
-- 
2.53.0