| From: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, David Rowley <dgrowleyml(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)kurilemu(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Re: Fix relation statistics around transactional TRUNCATE |
| Date: | 2026-11-30 22:42:19 |
| Message-ID: | CAN12+YLxAQGjFKL9V59EQ1Ko0FKNyDvrAuMRKF7BP3rKwShxkA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I only looked at the tests of v1-0001 so far and did not do a deeper
review of the patches. The trunc_stats_test6 case is clearly a bug,
and the patch fixes it.
However, I am not sure about the expected results for trunc_stats_test8
and trunc_stats_test9.
```
SELECT relname, n_tup_ins, n_dead_tup, n_ins_since_vacuum
FROM pg_stat_user_tables
WHERE relname IN ('trunc_stats_test8', 'trunc_stats_test9')
ORDER BY relname;
relname | n_tup_ins | n_dead_tup | n_ins_since_vacuum
-------------------+-----------+------------+--------------------
trunc_stats_test8 | 0 | 0 | 5
trunc_stats_test9 | 2 | 2 | 9
(2 rows)
```
In both tests the TRUNCATE is rolled back, so the inserts done after it
went into the new relfilenode, which is discarded. Those tuples never
exist in the table, so there is nothing for autovacuum to do for them,
and n_tup_ins and n_dead_tup don't count them either.
Shouldn't n_ins_since_vacuum be 0 and 2 here? Maybe I am missing the
reasoning for counting them?
FWIW, without the patch these report 0 and 2, so the patch changes the
behavior for these cases.
Regards,
Sami Imseih
Amazon Web Services (AWS)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-11-30 22:46:46 | Re: Disable startup progress timeout during standby WAL replay |
| Previous Message | Zsolt Parragi | 2026-11-30 22:35:04 | Re: pgstat: Flush some statistics within running transactions, take 2 |