Re: HashAggregate loses worker spill stats on rescan

From: Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: Osama Abdul Qader <osamaabdulqaderpostgres(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HashAggregate loses worker spill stats on rescan
Date: 2026-11-25 13:57:14
Message-ID: CAHza6qdp1h3bt2RgtfX+b6KDxRpy=8Y=9z+iNo7_Z5GTL6wsSA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ayush,

> HashAgg seems to lose the worker's spill stats when Gather is rescanned.

I looked at v1, and it LGTM.
I had noticed the same problem and posted a patch in another thread [1],
but as David pointed out, it was a duplicate, so I've withdrawn it. The
two differ only in how the following part is written, and they gave the
same results.

Yours:
+ if (si->hash_batches_used == 0)
+ si->hash_batches_used = node->hash_batches_used;
+ else
+ si->hash_batches_used += node->hash_batches_used - 1;

Mine:
+ si->hash_batches_used = Max(si->hash_batches_used, 1) +
+ node->hash_batches_used - 1;

I wrote it this way because I couldn't find a similar if...else in other
nodes, and it can be written more simply without one. But I think it's
just a matter of taste.

Regards,
Tatsuya Kawata

[1]
https://www.postgresql.org/message-id/flat/CAHza6qfgOQ0Psd5kbYkHn2RCAOfcBMvRohUX3SUptd1kZj6euA%40mail.gmail.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-25 14:01:30 Re: Should we skip foreign key checks in binary upgrade mode?
Previous Message torikoshia 2026-11-25 13:53:06 Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations?