| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Should HashSetOp go away |
| Date: | 2025-10-31 18:09:48 |
| Message-ID: | 3741486.1761934188@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
I wrote:
> * create_setop_path's required-space estimate of entrysize * numGroups
> was rather lame before commit 5dfc19814, and it's even more so
> afterwards. It's basically only accounting for the tuples themselves,
> and not either the hashtable overhead or the SetOpStatePerGroupData
> counter space. With wide tuples that might disappear into the noise,
> but with only 16-ish data bytes per tuple it's all about the overhead.
> On my machine this example uses 80 bytes per tuple in the "SetOp hash
> table" context and another 16 or more in the simplehash hashtable.
> So about triple what the planner thought.
> * To do better, we probably need to take this computation out of the
> planner and have execGrouping.c expose a function to estimate the
> TupleHashTable size for N entries and such-and-such average data
> width. That in turn will require simplehash.h to expose a function
> for estimating the size of its tables, because AFAICS its callers are
> not supposed to know such details.
Here's a pair of patches to try to do better. The first one
is concerned with getting more realistic size estimates for
TupleHashTables in the planner. The second is some mop-up
that's been pending for a long time in the same area, namely
getting rid of "long int" field types in Plan nodes.
With 0001, the planner's estimate of the amount of space needed
for your example query seems to be pretty dead-on, at least in
non-debug builds.
regards, tom lane
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Improve-planner-s-estimates-of-tuple-hash-table-s.patch | text/x-diff | 17.8 KB |
| v1-0002-Change-long-numGroups-fields-to-be-Cardinality-i..patch | text/x-diff | 19.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Borodin | 2025-10-31 18:13:56 | Re: [PATCH] Add archive_mode=follow_primary to prevent unarchived WAL on standby promotion |
| Previous Message | Álvaro Herrera | 2025-10-31 18:02:32 | Re: pg_createsubscriber --dry-run logging concerns |