| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | assam258(at)gmail(dot)com |
| Cc: | Tatsuo Ishii <ishii(at)postgresql(dot)org>, zsolt(dot)parragi(at)percona(dot)com, sjjang112233(at)gmail(dot)com, vik(at)postgresfriends(dot)org, er(at)xs4all(dot)nl, jacob(dot)champion(at)enterprisedb(dot)com, david(dot)g(dot)johnston(at)gmail(dot)com, peter(at)eisentraut(dot)org, li(dot)evan(dot)chao(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Row pattern recognition |
| Date: | 2026-11-01 04:16:45 |
| Message-ID: | CACJufxEL16uvmrfnhfPO0qF959w+9fn+N7HggHb+_yYa-5NUZw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
CREATE VIEW v3 AS
SELECT
FROM (VALUES (1,'A'),(2,'B'),(3,'B')) t(id, v)
WINDOW w AS (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
AFTER MATCH SKIP TO NEXT ROW
PATTERN (A B C | B)
DEFINE A AS true, b as true, c as true);
\sv v3
PATTERN (A B C | B)
can be interpreted as
PATTERN (A B (C | B))
or
PATTERN ((A B C) | B)
We need extra parentheses to disambiguate it.
(I searched for "parentheses"; it seems this issue has never been discussed.)
Another question:
PATTERN (A B ?c)
is interpreted as
PATTERN (A B? c)
Maybe one para in select.sgml is enough to explain this, no need to
use parentheses to wrap it as
PATTERN (A (B?) c)
While looking at it, i think the below paragraph is not necessary.
The manual is generally not the place to explain implementation
shortcomings, and the RPR documentation is already quite long.
<para>
Two planner optimizations are not applied to a window that uses row
pattern recognition. A filter on the result of a monotonic window
function, such as <literal>rn <= 3</literal> on
a <function>row_number()</function> computed in a subquery, is not
pushed down into the window as a run condition, so the window is
evaluated to the end of the partition instead of stopping early. And
the frame clause is not replaced with a cheaper one, even when the
window functions using it do not depend on the frame. Query results
are not affected, only the cost of evaluating the window.
</para>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | mingjiegao | 2026-11-01 04:19:34 | [PATCH v1] Fix initial sync of zero-column published tables |
| Previous Message | Manu | 2026-11-01 03:48:21 | Re: O(N^3) planning time in choose_plan_name() since 8c49a484e8e |