| From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | scale parallel_tuple_cost by tuple width |
| Date: | 2026-03-30 13:27:08 |
| Message-ID: | e9f24286-068e-40cb-a6a9-25a4f938672a@dunslane.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
While investigating a performance issue, I found that it was extremely
difficult to get a parallel plan in some cases due to the fixed
parallel_tuple_cost. But this cost is not really fixed - it's going to
be larger for larger tuples. So this proposal adjusts the cost used
according to how large we expect the results to be. The result is that
in the common case where, say, you're getting a group id and some
aggregates, a parallel plan is more likely to be chosen. By contrast,
queries that generate very wide results will be less likely to choose
parallel plans. The formula chosen does have a fixed cost piece built
into it, which accounts for the shm_mq_sendv() and shm_mq_receive()
synchronization that occurs regardless of width.
The patch itself is pretty simple.
Also attached is a benchmark report that I had claude create. Its main
result shows a speedup of about 2.7x.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Scale-parallel_tuple_cost-by-tuple-width-at-Gather-n.patch | text/x-patch | 6.1 KB |
| parallel-tuple-cost-benchmark-2026-03-30.txt | text/plain | 8.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2026-03-30 13:29:47 | Re: Teach isolation tester about injection points in background workers |
| Previous Message | Amul Sul | 2026-03-30 13:09:32 | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |