Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: dgrowleyml(at)gmail(dot)com
Cc: ashutosh(dot)bapat(dot)oss(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN
Date: 2024-09-06 06:02:37
Message-ID: 20240906.150237.57111972562260411.ishii@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Thanks for making the adjustments to this.
>
> I don't think there is any need to call tuplestore_updatemax() from
> within writetup_heap(). That means having to update the maximum space
> used every time a tuple is written to disk. That's a fairly massive
> overhead.
>
> Instead, it should be fine to modify tuplestore_updatemax() to set a
> flag to true if state->status != TSS_INMEM and then record the disk
> space used. That flag won't ever be set to false again.
> tuplestore_storage_type_name() should just return "Disk" if the new
> disk flag is set, even if state->status == TSS_INMEM. Since the
> work_mem size won't change between tuplestore_clear() calls, if we've
> once spilt to disk, then we shouldn't care about the memory used for
> runs that didn't. Those will always have used less memory.
>
> I did this quickly, but playing around with the attached, I didn't see
> any slowdown.

Your patch looks good to me and I confirmed that with your patch I
didn't see any slowdown either. Thanks!

Best reagards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2024-09-06 06:30:33 Re: Optimize WindowAgg's use of tuplestores
Previous Message David Rowley 2024-09-06 05:07:48 Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN