nocfbot-0007-Clarify-RPR-inverse-transition-comment.txt

text/plain

Filename: nocfbot-0007-Clarify-RPR-inverse-transition-comment.txt
Type: text/plain
Part: 6
Message: Re: Row pattern recognition
From 124119ef649d05bcd3e20f5e5a1c353a186f99db Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Fri, 20 Mar 2026 19:01:43 +0900
Subject: [PATCH] Clarify why RPR disables inverse transition optimization

When RPR is active, the reduced frame depends on pattern matching results
which can differ entirely from row to row. This makes it impossible to
use the inverse transition function to incrementally remove rows from the
aggregate state, so a full restart is required for every row.

Add a comment explaining this reasoning at the restart decision logic.
---
 src/backend/executor/nodeWindowAgg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index c92235c54c7..d144fa39375 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -853,7 +853,9 @@ eval_windowaggregates(WindowAggState *winstate)
 	 *	   transition function, or
 	 *	 - we have an EXCLUSION clause, or
 	 *	 - if the new frame doesn't overlap the old one
-	 *   - if RPR is enabled
+	 *   - if RPR (Row Pattern Recognition) is enabled, because the reduced
+	 *     frame depends on pattern matching results which can differ entirely
+	 *     from row to row, making inverse transition optimization inapplicable
 	 *
 	 * Note that we don't strictly need to restart in the last case, but if
 	 * we're going to remove all rows from the aggregation anyway, a restart
-- 
2.50.1 (Apple Git-155)