From c4943f2f4fbe264238b806e49e3ab486e15534dc Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Fri, 20 Mar 2026 20:45:20 +0900 Subject: [PATCH] Clarify RPR documentation in advanced.sgml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the absorption optimization paragraph explicitly reference the O(n²) complexity it mitigates, rather than using an ambiguous "this" that could be misread as referring to the pattern simplification paragraph immediately above. Also clarify the aggregate behavior description for non-starting rows: replace the vague "NULL or 0 depending on its aggregation definition" with concrete examples (count() returns 0, sum() returns NULL). --- doc/src/sgml/advanced.sgml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml index 3e696eefc66..1336f2daa14 100644 --- a/doc/src/sgml/advanced.sgml +++ b/doc/src/sgml/advanced.sgml @@ -585,10 +585,11 @@ DEFINE rows which satisfies the PATTERN is found, in the starting row all columns or functions are shown in the target list. Note that aggregations only look into the matched rows, rather than the whole frame. On the second or - subsequent rows all window functions are shown as NULL. Aggregates are - NULL or 0 depending on its aggregation definition. A count() aggregate - shows 0. For rows that do not match on the PATTERN, columns are shown AS - NULL too. Example of a SELECT using + subsequent rows all window functions are shown as NULL. Aggregates on + non-starting rows return their initial value: for example, + count() returns 0 and sum() + returns NULL. For rows that do not match the PATTERN, columns are shown + as NULL too. Example of a SELECT using the DEFINE and PATTERN clause is as follows. @@ -653,7 +654,8 @@ FROM stock - To mitigate this, PostgreSQL employs + To mitigate the O(n2) complexity described + above, PostgreSQL also employs a context absorption optimization. When a pattern starts with a greedy unbounded element, newer matching contexts cannot produce longer matches than older contexts. By detecting and eliminating these redundant -- 2.50.1 (Apple Git-155)