Re: Improve hash aggregate spilling by writing only the needed columns

From: Mario Karuza <mkaruza(dot)pg(at)icloud(dot)com>
To: Xiaoxuan Li <xiaoxuan(dot)li(dot)dev(at)gmail(dot)com>, Ethan Tran <ethantran(at)quwin(dot)dev>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improve hash aggregate spilling by writing only the needed columns
Date: 2026-11-06 13:41:47
Message-ID: e96416e4-23ea-4b9b-8354-a129918c22e4@icloud.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ethan, Xiaoxuan,

Thanks for the reviews.

Attached is v2, rebased on current master (4a934833fb0):

1. Fixed the JIT crash reported by Xiaoxuan.

FIELDNO_AGGSTATE_ALL_PERGROUPS is bumped to 55. I kept
hash_spill_colmap next to the other spill fields rather
than moving it after all_pergroups.

2. Used Ethan lazy initialization.

The compact spill slot and column map are now built on the first
spill, so executions that never spill don't pay any cost.
Thanks for providing patch.

> Make them void?

hashagg_spill_tuple() already returns Size on master, and both
callers discard it there too, so I left it unchanged to keep
patch with minimal changes.

Attachment Content-Type Size
v2-0001-Write-only-the-needed-columns-to-hash-aggregate-s.patch text/plain 9.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-11-06 13:42:58 Re: BGWORKER_INTERRUPTIBLE workers are never restarted after DROP/ALTER/CREATE DATABASE
Previous Message Etsuro Fujita 2026-11-06 13:20:54 postgres_fdw: virtual generated columns vs. IMPORT FOREIGN SCHEMA