Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Lukas Fittl <lukas(at)fittl(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment
Date: 2025-03-20 14:03:25
Message-ID: f68e7271-4648-4e0f-882f-f4e93bc9c9cf@tantorlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 20.03.2025 15:32, Andrei Lepikhov wrote:
> I quite frequently need the number of distinct values (or groups)
> predicted during the Memoize node creation to understand why caching
> is sometimes employed or not.
> But I had thought about an alternative way: having an extensible
> EXPLAIN (thanks to Robert), we may save optimisation-stage data (I
> have the same necessity in the case of IncrementalSort, for example)
> and put it into the Plan node on-demand. So, the way I want to go is a
> Plan::extlist node and create_plan hook, which may allow copying
> best_path data to the final plan. So, here, we will add a new
> parameter and avoid touching the core code.
> But I would give +1 to current approach if it were done in a shorter
> time.

Then before proceeding further, I think we need to benchmark this change
to ensure there are no performance regressions. If performance issues
arise, then using extensible EXPLAIN might be the only viable approach.

I have addressed most of the review comments except for the
ExplainPropertyText change. I am attaching v3 of the patch with these
updates. If anyone notices any performance issues, please let me know.
Issue with ExplainPropertyText for this thread I'll fix in the next
patches if it will be necessary.

So far, I have tested it on small machines. There are no performance
issues yet. I'll run benchmarks on larger ones soon.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC.

Attachment Content-Type Size
v3-0001-Show-ndistinct-and-est_entries-in-EXPLAIN-for-Memoize.patch text/x-patch 5.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-03-20 14:04:08 Re: making EXPLAIN extensible
Previous Message Álvaro Herrera 2025-03-20 13:16:36 Re: TOAST versus toast