Re: [Patch] New pg_stat_tablespace view

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Bernd Reiß <bd_reiss(at)gmx(dot)at>, Ahmed Gouda <ahmed(dot)gouda(at)cybertec(dot)at>, Andres Freund <andres(at)anarazel(dot)de>, songjinzhou <tsinghualucky912(at)foxmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: [Patch] New pg_stat_tablespace view
Date: 2026-10-09 04:49:20
Message-ID: CAGRkXqQsLfecnoA+NZvMW+Q2Z+nKGsdexeignD6utE0RWsHdQA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Zsolt,

Thanks, both are real. v10 is attached.

> 1: there's a window for a permanent statistics leak when a tablespace
> is dropped.

Fixed. A flush only looks up the entry now. If it is gone, the counts
are dropped.

CREATE TABLESPACE creates the entry, as you suggested. That alone
misses pg_default, standbys, and everything after a crash. So a
process also creates it the first time it counts something for a
tablespace. A relation or a temp file in the tablespace is in use at
that moment, so it cannot be dropped.

Your spec is in the patch as an isolation test.

> 2: Are you sure the transaction move behavior is correct?

No, it was wrong. Counts from before the move now go to the old
tablespace. The test checks both tablespaces.

Andres, counting a block time is now an add into a small local array.
v9 did a hash lookup each time the tablespace changed. The only lookup
now is when a tablespace is added to that array, once per tablespace
between two flushes.

Thanks,
Shihao

Attachment Content-Type Size
pg_stat_tablespace-v10.patch application/octet-stream 81.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-10-09 04:57:30 Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish
Previous Message Sho Ito 2026-10-09 04:48:20 Re: [PATCH v1] Reject zero resource kinds in test_resowner_many()