Parallel safety docs for CTEs

Started by James Colemanabout 1 year ago3 messages
#1James Coleman
jtc331@gmail.com
1 attachment(s)

Hello,

A colleague noticed today that the docs still say that "Scans of
common table expressions (CTEs)" are "always parallel restricted".

While I think that strictly remains true at the implementation level,
from a user's perspective I think that's not been true since the
change to default to trying to inline CTEs rather than defaulting to
materializing them.

Attached is a patch to slightly modify the language; would be happy to
hear suggestions on a better way to improve this.

Regards,
James Coleman

Attachments:

v1-0001-Update-parallel-safety-docs-for-CTE-optimizations.patchapplication/octet-stream; name=v1-0001-Update-parallel-safety-docs-for-CTE-optimizations.patchDownload
From f07b28dfdcf65ed00514d9a8a6f1d07b39fae6c2 Mon Sep 17 00:00:00 2001
From: jcoleman <jtc331@gmail.com>
Date: Tue, 19 Nov 2024 14:11:42 -0500
Subject: [PATCH v1] Update parallel safety docs for CTE optimizations

---
 doc/src/sgml/parallel.sgml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/src/sgml/parallel.sgml b/doc/src/sgml/parallel.sgml
index 1ce9abf86f..555522a7e6 100644
--- a/doc/src/sgml/parallel.sgml
+++ b/doc/src/sgml/parallel.sgml
@@ -493,7 +493,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
   <itemizedlist>
     <listitem>
       <para>
-        Scans of common table expressions (CTEs).
+        Scans of common table expressions (CTEs) which must be materialized.
       </para>
     </listitem>
 
-- 
2.39.3 (Apple Git-146)

#2James Coleman
jtc331@gmail.com
In reply to: James Coleman (#1)
Re: Parallel safety docs for CTEs

On Tue, Nov 19, 2024 at 2:16 PM James Coleman <jtc331@gmail.com> wrote:

Hello,

A colleague noticed today that the docs still say that "Scans of
common table expressions (CTEs)" are "always parallel restricted".

While I think that strictly remains true at the implementation level,
from a user's perspective I think that's not been true since the
change to default to trying to inline CTEs rather than defaulting to
materializing them.

Attached is a patch to slightly modify the language; would be happy to
hear suggestions on a better way to improve this.

Regards,
James Coleman

I'd forgotten to make a commit fest record for this and stumbled upon
it today. See https://commitfest.postgresql.org/patch/5650/

Regards,
James Coleman

#3Kirill Reshke
reshkekirill@gmail.com
In reply to: James Coleman (#2)
Re: Parallel safety docs for CTEs

On Wed, 12 Mar 2025 at 22:11, James Coleman <jtc331@gmail.com> wrote:

On Tue, Nov 19, 2024 at 2:16 PM James Coleman <jtc331@gmail.com> wrote:

Hello,

A colleague noticed today that the docs still say that "Scans of
common table expressions (CTEs)" are "always parallel restricted".

While I think that strictly remains true at the implementation level,
from a user's perspective I think that's not been true since the
change to default to trying to inline CTEs rather than defaulting to
materializing them.

Attached is a patch to slightly modify the language; would be happy to
hear suggestions on a better way to improve this.

Regards,
James Coleman

I'd forgotten to make a commit fest record for this and stumbled upon
it today. See https://commitfest.postgresql.org/patch/5650/

Regards,
James Coleman

Hi!

Looks like current .sgml docs leak description of what CTE inlining
(and CTE materialising) is, and when CTE inlining applies. We only
have regression tests on this.
So, maybe we should define CTE inlining and CTE materialising, and
only then commit this change?

--
Best regards,
Kirill Reshke