Re: making EXPLAIN extensible
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeff Davis <pgsql@j-davis.com>, Thom Brown <thom@linux.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-03-07T15:05:52Z
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 →
-
pg_overexplain: Use PG_MODULE_MAGIC_EXT.
- 83ccc85859f3 18.0 landed
-
pg_overexplain: Call previous hooks as appropriate.
- 9f0c36aea0fb 18.0 landed
-
pg_overexplain: Additional EXPLAIN options for debugging.
- 8d5ceb113e3f 18.0 landed
-
Add an additional hook for EXPLAIN option validation.
- 50ba65e73325 18.0 landed
-
Add some new hooks so extensions can add details to EXPLAIN.
- 4fd02bf7cf94 18.0 landed
-
Make it possible for loadable modules to add EXPLAIN options.
- c65bc2e1d14a 18.0 landed
Attachments
- v6-0002-Add-some-new-hooks-so-extensions-can-add-details-.patch (application/octet-stream) patch v6-0002
- v6-0001-Make-it-possible-for-loadable-modules-to-add-EXPL.patch (application/octet-stream) patch v6-0001
- v6-0003-pg_overexplain-Additional-EXPLAIN-options-for-deb.patch (application/octet-stream) patch v6-0003
On Thu, Mar 6, 2025 at 4:24 PM Robert Haas <robertmhaas@gmail.com> wrote: > On Thu, Mar 6, 2025 at 4:16 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > I find a good deal of attraction in getting rid of the IDs and > > just using names. Nor do I believe we need a hash table. > > (1) Surely there will not be so many extensions using this within a > > single EXPLAIN that a simple loop with strcmp()'s isn't good enough. > > (2) The IDs aren't free either; where will an extension keep the > > ID it assigned? We're trying to move away from global variables. > > > > But, if you're convinced otherwise, the current design is OK. > > Interesting. I hadn't even considered just iterating every time to > find the ID, but I agree with you that might be totally fine. As you > say, we're not expecting there to be many extensions here. I can try > coding that up and see how it looks (or you can, if you like). Here's v6, doing it that way. I found that the simplest thing to do was just push the call to GetExplainExtensionId() inside Get/SetExplainExtensionState(). With this approach, the backend-scope IDs still exist, but they are private to explain_state.c. An alternate design could be to make each individual ExplainState have its own list of extension names alongside its own list of opaque pointers, so that the IDs become ExplainState-scoped rather than backend-scoped. At the moment, that seems to me to be just deciding to make the code more complicated for no obvious benefit, but maybe I'm missing something. At any rate, my overall conclusion here is that this is giving up a probably-insignificant amount of performance for an also-not-terribly-significant abstraction improvement, so I find it a little hard to get excited about it one way or the other, but it's fine. Tom, what do you think? Thanks, -- Robert Haas EDB: http://www.enterprisedb.com