| From: | Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Add TOAST statistics columns to pg_stat_all_tables |
| Date: | 2026-09-16 12:14:35 |
| Message-ID: | CAOzEurQTJDHQmG0xekQapZDM-DaoK1-5sK03PABrMZ2Er=zZKA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Sep 15, 2026 at 6:48 AM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> The join is also not needed. T.oid holds the same value as
> C.reltoastrelid, which you already use via NULLIF(C.reltoastrelid, 0)
> for the toast_relid column. Pass that same expression to the three
> functions, drop the join and the T.oid in GROUP BY, and the time goes
> back to 20.7 ms with the same output. I checked all four columns over
> 15,120 rows, including materialized views and partitioned tables.
Thanks for testing and measuring this. You are right, and v2 does it
that way. Removing the join also leaves the FROM clause and GROUP BY
list untouched, so the patch now only adds columns.
> One note on the test. Temporary tables are never autovacuumed, so
> toast_last_autovacuum is always NULL there and toast_autovacuum_count
> is always 0. Checking the new columns against the TOAST table's own row
> would catch a wrong OID:
Adopted. v2 compares all four columns against the TOAST table's own
row in pg_stat_all_tables. I also changed the lookup from relname to
'stats_toast_test'::regclass, so the test cannot match a same-named
table from another session under installcheck.
--
Shinya Kato
NTT OSS Center
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Add-TOAST-statistics-columns-to-pg_stat_all_table.patch | application/octet-stream | 11.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul Kim | 2026-09-16 12:26:22 | Re: Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish |
| Previous Message | Nazir Bilal Yavuz | 2026-09-16 12:14:11 | Re: GetRelationPath() vs critical sections |