Re: plan shape work
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>,
Alexandra Wang <alexandra.wang.oss@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
"bruce@momjian.us" <bruce@momjian.us>, lepihov@gmail.com
Date: 2025-09-26T14:23:21Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Assign each subquery a unique name prior to planning it.
- 8c49a484e8eb 19 (unreleased) landed
-
Keep track of what RTIs a Result node is scanning.
- f2bae51dfd5b 19 (unreleased) landed
Richard Guo <guofenglinux@gmail.com> writes: > Looking at choose_plan_name(), IIUC, the nested loop is used to find > the next unused suffix number for a given name. I'm wondering why not > simply iterate through glob->subplanNames once, check the suffix > number for each name matching the given base name, determine the > current maximum suffix, and then use "max_suffix + 1" as the next > unused suffix. This approach requires only a single pass through the > list, and if there's a bug, the worst-case scenario would be a > duplicate name rather than an infinite loop. It seems to me that this > approach is both more efficient and less risky. "simply" is perhaps not the right adjective there. My guess is that this approach nets out to more code, more possibilities for bugs (especially in cases where one name is a prefix of another), and will be slower in typical cases with just a few subplan names. As an example of edge cases that your idea introduces, what happens if a user-written subquery name is "expr_999999999999999999999999" and then we need to generate a unique name based on "expr"? Now we have an integer-overflow situation to worry about, with possibly platform-dependent results. But it's Robert's patch, so he gets to make the call. regards, tom lane