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 1w3xlS-001izi-1M for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2026 14:57:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w3xlQ-00AigY-2l for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2026 14:57:21 +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 1w3xlQ-00Aifl-1Q for pgsql-hackers@lists.postgresql.org; Sat, 21 Mar 2026 14:57:20 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w3xlP-00000000Kw8-0Hfz for pgsql-hackers@postgresql.org; Sat, 21 Mar 2026 14:57:20 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-35bb9070644so935521a91.2 for ; Sat, 21 Mar 2026 07:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774105038; cv=none; d=google.com; s=arc-20240605; b=PtN41TIpIpRh+n91K8173kYQhE3G6BRc6WZHKToj8hFEUufJ0yeR71ujXAwZh8pluu MLXCTq5UPXxiM4C1lpBb9MS1zxxQ5JVTaUVuWcM38iY8Dw71lUKHewSZeqRws3OrrMrU TtrOkHZiPZ8wtlc28S7IwngUe7qtBIAZMcz4iTTEUOiD38WEh5RnwBZuhDX8M/HeC/K5 2VQSws5OHqCr/sk8oYCXQurOKab0VAiQfE2Tux9ftNFlgTppVBYZjrEjhenCNm2CP8O3 LNQNyp5hc6PcUfMLpR1ZN6mSqb0eU539M9pfeYW+Kp9cuTF1pz+dA2LPXlQbxmUazPWd cjlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:dkim-signature; bh=pcwgqntI0r4NKUOEnBu3smlL8yWFEkGzphACvHnO64Q=; fh=HsLQ/ANZfwiNiCCF1SUoTnqp40uL7YSNxX6PbUsYmbg=; b=Q4vcB+aa3pAZZHGNNoZf0EWvq4Yx4JaBzStrLinw0Dar3bnvL6006fSBGfifVwuK3/ fPvKKp35A+jWnVIMq4Pg6Kww9pyNQTGUjNIiFDAf5Yd/d7ptU068X9rojEb1f1IQ0NAY 12aOsjoGcNzSxw9bropd2Bc3k8/RFm5KzMJsFrTsH7gr53ndm1XkPj7Y8spP9NT/sm1q UeAAWOgPfIxETlxNDC+KMT2txbAV5ojp4iOdDAgDbzuqoQDmax+ig2nqMDs+7mB41IRz v9E2efVTpnd/Fp8JLx0ogdAnQ2JVxQEGkcjeFegXxS6bePHvAOj9FbsJ+x7g50RxdsDe fecQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774105038; x=1774709838; darn=postgresql.org; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pcwgqntI0r4NKUOEnBu3smlL8yWFEkGzphACvHnO64Q=; b=VwFuXvc1mWFkOo8nTApkVPSl5626rcGQDDMLSFercDzkUTjUb+1+L2iwlUKGZnQ0Cn QE7j6P2wSj5tKYybKe08BCKFwRZmNqBqp+yVE/CgBAF+VNTWijReH+GF9HOY1Sp/jX3+ 6/BcjC5V16AGqlFStOjIdct72Xx8bFIBoiSYI2F59XK5mHHJ3lX388uvVF7xCUAFabaf VR0uEohFkFmZw/Z4yBxIpCHmfJ0geunzXCKRYqcce9psrvfcrLIc2hQRUKyvju2xQpsg jKEB8xum46CXAzfOkBvUVTd5IkNGfOREnKCmJlMIH/WVh2hvpNeuqXjEsuBWPIPH0yxs 2law== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774105038; x=1774709838; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pcwgqntI0r4NKUOEnBu3smlL8yWFEkGzphACvHnO64Q=; b=rb5/BdtQ0VEhSgUpGR3ZQ/1GP3booiMbZFPQf5uvjQei8Rvul1wpe0dRkXfADV6UF5 S/b+fvAHrp3zL2LAWJEY46ndNUXQARiJFNVF83q5oTvUDryd+gQcKlbew+93PDQ+cdDu oNkNpjBeE0IHebvBCEstd5uKr+lrQ6D5l9RAk9eX1ltPcj6jkSCiuk0vPYL5o8wgQlbW Jly82j0iacyI37kYjkzE7YftZZGrNgEgGpY3+39morGHwMYt9p2o48ih/uTAe0MgKPgq uBXgMo2com2AQ6UNKTLfEa4ABPpH6p3y3sQH63CPppeheCPeNjBu/CdskKiccH35JXbl XNQg== X-Forwarded-Encrypted: i=1; AJvYcCX7ZHNaSYFib/v/q8R967eYcWX4ur1ZARAk10urorM4fvPK3H3RXuRBZ9z+ZNokJ6Lx0xIW+N9ZxsHjrUaZ@postgresql.org X-Gm-Message-State: AOJu0Yw1iZasjklLCpXucSBlfTWCY7aQapnj/AUk5QxDLFBLbb4ZhRng 7HCqjv//d+5mXKExbeEGz8ovMTz+34mPGD4W4v9eQptuWXtBNyBwN/SO2+mSjjDNKjfrGeNc4WU l74VDBInKUMaL0SKq6HSkotk9WAEsy+Q= X-Gm-Gg: ATEYQzxOI/qyBAjiDYuYmAkZBBMjIVYJ+DEkTAKscbjRrxAOiR8MkL+CRjGhyUeeRIk jLQNpIeZUoxoNvncvcCgFB01kh2WLfYbYPw/U1rlb2j6OSNyYxQd+InShLsX94evE/7Tz2K3mPy ZCcA5LjxTLOpZLZ+nzptCe61pLcePoFcxh1MXAT5PU1BZkDLgHgo+qZur72EExqr7xCA7mOPCUJ KkROLe+bT7/cpdbQhazuMI6FyawLh3I//7VsVVoIqr5bXijByUpCtb4Fs+ByiKHF2TS4R2Nm/Hu xiZSq6mfB6lyTuSUiROb4fHOoz/YPJnb1cXiJGA/ X-Received: by 2002:a17:90b:4a48:b0:35b:929f:7e8d with SMTP id 98e67ed59e1d1-35bd2bf6528mr5467560a91.14.1774105038201; Sat, 21 Mar 2026 07:57:18 -0700 (PDT) MIME-Version: 1.0 References: <20260321.140232.1947157589839395257.ishii@postgresql.org> <20260321.231629.266287379124559013.ishii@postgresql.org> In-Reply-To: <20260321.231629.266287379124559013.ishii@postgresql.org> Reply-To: assam258@gmail.com From: Henson Choi Date: Sat, 21 Mar 2026 23:57:06 +0900 X-Gm-Features: AaiRm51izq-RMQRLmD9ria4ZT0HEJYWZa_fzxXklVq1NdWWvpqQAZjAPvaNW24s Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii Cc: zsolt.parragi@percona.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="00000000000098a829064d8a0482" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000098a829064d8a0482 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2026=EB=85=84 3=EC=9B=94 21=EC=9D=BC (=ED=86=A0) 23:16, Tatsuo Ishii =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > Hi Henson, > > >> So, if RPR is active, WinSetMarkPosition() is not called at all? That > >> seems too strong limitation. Can't we set mark at frameheadpos even > >> if RPR is active? It seems safe since the only allowed franme start > >> option is ROWS BETWEEN CURRENT ROW and we never step back to the rows > >> before frameheadpos. > > > > > > You raise a valid point. Setting mark at frameheadpos would be safe > > for the window function's own read pointer, since we only allow > > ROWS BETWEEN CURRENT ROW. > > > > However, the difficulty is with the PREV/NEXT navigation. In the > > experimental patch, PREV accepts an optional offset argument -- > > e.g. PREV(price, N) -- and this offset can be a runtime expression > > whose value is not known until evaluation time. If the mark is > > advanced to frameheadpos, PREV(price, N) with a large N could try > > to access rows that the tuplestore has already truncated. > > > > This is why the experimental patch takes a different approach: it > > creates a separate nav_winobj with its own mark pointer pinned at > > position 0, so that the tuplestore never truncates rows that PREV > > might need. The window function's own mark management is left > > unchanged. > > > > The mark=3D0 approach is safe but conservative -- it prevents the > > tuplestore from releasing any rows within the partition. The SQL > > standard (ISO/IEC 19075-5, Subclause 5.6.2) requires the offset > > argument to be a "runtime constant" -- meaning it cannot reference > > columns or row pattern variables. So in practice, the maximum > > offset is always known at plan time, which opens the door for a > > future optimization: advance the mark to (currentpos - max_offset) > > when all PREV offsets in the DEFINE clause are constant. > > > > Since the experimental patch redesigns how mark works for PREV/NEXT > > navigation, I think we should drop 0004 from the current series > > and revisit the set_mark question together with the experimental > > patch. What do you think? > > Agreed. So I just want to make sure I create v46 using 0001-0003 and > 0005-0015. Am I correct? Yes, that=E2=80=99s right!=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2= =80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80= =8B=E2=80=8B=E2=80=8B > Best regards, > -- > Tatsuo Ishii > SRA OSS K.K. > English: http://www.sraoss.co.jp/index_en/ > Japanese:http://www.sraoss.co.jp > --00000000000098a829064d8a0482 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


2026=EB=85=84 3=EC=9B=94 21=EC=9D=BC (= =ED=86=A0) 23:16, Tatsuo Ishii <= ishii@postgresql.org>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1:
Hi Henson,

>> So, if RPR is active, WinSetMarkPosition() is not called at all?= =C2=A0 That
>> seems too strong limitation.=C2=A0 Can't we set mark at frameh= eadpos even
>> if RPR is active? It seems safe since the only allowed franme star= t
>> option is ROWS BETWEEN CURRENT ROW and we never step back to the r= ows
>> before frameheadpos.
>
>
> You raise a valid point. Setting mark at frameheadpos would be safe > for the window function's own read pointer, since we only allow > ROWS BETWEEN CURRENT ROW.
>
> However, the difficulty is with the PREV/NEXT navigation. In the
> experimental patch, PREV accepts an optional offset argument --
> e.g. PREV(price, N) -- and this offset can be a runtime expression
> whose value is not known until evaluation time. If the mark is
> advanced to frameheadpos, PREV(price, N) with a large N could try
> to access rows that the tuplestore has already truncated.
>
> This is why the experimental patch takes a different approach: it
> creates a separate nav_winobj with its own mark pointer pinned at
> position 0, so that the tuplestore never truncates rows that PREV
> might need. The window function's own mark management is left
> unchanged.
>
> The mark=3D0 approach is safe but conservative -- it prevents the
> tuplestore from releasing any rows within the partition. The SQL
> standard (ISO/IEC 19075-5, Subclause 5.6.2) requires the offset
> argument to be a "runtime constant" -- meaning it cannot ref= erence
> columns or row pattern variables. So in practice, the maximum
> offset is always known at plan time, which opens the door for a
> future optimization: advance the mark to (currentpos - max_offset)
> when all PREV offsets in the DEFINE clause are constant.
>
> Since the experimental patch redesigns how mark works for PREV/NEXT > navigation, I think we should drop 0004 from the current series
> and revisit the set_mark question together with the experimental
> patch. What do you think?

Agreed. So I just want to make sure I create v46 using 0001-0003 and
0005-0015. Am I correct?

Yes, that=E2=80=99s right!=E2=80= =8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B= =E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B=E2=80=8B


Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
--00000000000098a829064d8a0482--