Propagate pathkeys from CTEs up to the outer query

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Propagate pathkeys from CTEs up to the outer query
Date: 2024-01-29 03:18:51
Message-ID: CAMbWs49xYd3f8CrE8-WW3--dV1zH_sDSDn-vs2DzHj81Wcnsew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In [1] we've reached a conclusion that for a MATERIALIZED CTE it's okay
to 'allow our statistics or guesses for the sub-query to subsequently
influence what the upper planner does'. Commit f7816aec23 exposes
column statistics to the upper planner. In the light of that, here is a
patch that exposes info about the ordering of the CTE result to the
upper planner.

This patch was initially posted in that same thread and has received
some comments from Tom in [2]. Due to the presence of multiple patches
in that thread, it has led to confusion. So fork a new thread here
specifically dedicated to discussing the patch about exposing pathkeys
from CTEs to the upper planner.

Comments/thoughts?

[1] https://www.postgresql.org/message-id/482957.1700192299%40sss.pgh.pa.us
[2] https://www.postgresql.org/message-id/1339607.1700502358%40sss.pgh.pa.us

Thanks
Richard

Attachment Content-Type Size
v3-0001-Propagate-pathkeys-from-CTEs-up-to-the-outer-query.patch application/octet-stream 9.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-01-29 03:19:53 Re: Wrong rows estimations with joins of CTEs slows queries by more than factor 500
Previous Message Kyotaro Horiguchi 2024-01-29 03:12:00 Re: More new SQL/JSON item methods