| From: | Manu <manuelreyesbravo(at)gmail(dot)com> |
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ayoub Kazar <ayoub(dot)kazar(at)data-bene(dot)io>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: O(N^3) planning time in choose_plan_name() since 8c49a484e8e |
| Date: | 2026-11-03 14:54:43 |
| Message-ID: | 179371768379.1836248.10389390142664023334@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Robert,
On Tue, Nov 3, 2026 at 9:21 AM Robert Haas <robertmhaas(at)gmail(dot)com>
wrote:
> It's also important that the set of names we end up with
> doesn't depend on what the planner chooses to do. We want expr_5 to
> mean the same thing no matter how the query gets planned, because
> advice strings can refer to it.
On master that already doesn't hold when a custom plan folds a sublink
away:
CREATE TABLE t (a int, b int); CREATE TABLE t2 (a int, b int);
PREPARE p(int) AS
SELECT CASE WHEN $1 = 0 THEN NULL
ELSE (SELECT sum(b) FROM t2 WHERE a = t.a AND b = 1) END,
(SELECT sum(b) FROM t2 WHERE a = t.a AND b = 2),
(SELECT sum(b) FROM t2 WHERE a = t.a AND b = 3)
FROM t;
With EXECUTE p(0), the custom plan names the b = 2 and b = 3 sublinks
expr_1 and expr_2, and the generic plan names them expr_2 and expr_3,
so expr_2 is a different subquery in each. v5 keeps master's names,
so it behaves the same; a single counter would extend this to
subplans of other kinds.
Regards,
Manu
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2026-11-03 14:57:48 | Re: First draft of PG 19 release notes |
| Previous Message | Fujii Masao | 2026-11-03 14:53:12 | Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring |