Re: Tracking last scan time
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Dave Page <dpage@pgadmin.org>, Vik Fearing <vik@postgresfriends.org>, Matthias van de Meent <boekewurm+postgres@gmail.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2022-10-12T22:52:36Z
Lists: pgsql-hackers
Attachments
Hi, On 2022-10-12 12:50:31 -0700, Andres Freund wrote: > I think this should have at a basic test in src/test/regress/sql/stats.sql. If > I can write one in a few minutes I'll go for that, otherwise will reply > detailing difficulties. Took a bit longer (+lunch). Attached. In the attached 0001, the patch to make GetCurrentTransactionStopTimestamp() set xactStopTimestamp, I added a few comment updates and an Assert() to ensure that CurrentTransactionState->state is TRANS_(DEFAULT|COMMIT|ABORT|PREPARE). I am worried that otherwise we might end up with someone ending up using it in a place before the end of the transaction, which'd then end up recording the wrong timestamp in the commit/abort record. For 0002, the commit adding lastscan, I added catversion/stats version bumps (because I was planning to commit it already...), a commit message, and that minor docs change mentioned earlier. 0003 adds the tests mentioned above. I plan to merge them with 0002, but left them separate for easier review for now. To be able to compare timestamps for > not just >= we need to make sure that two subsequent timestamps differ. The attached achieves this by sleeping for 100ms between those points - we do that in other places already. I'd started out with 10ms, which I am fairly sure would suffice, but then deciced to copy the existing 100ms sleeps. I verified tests pass under valgrind, debug_discard_caches and after I make pgstat_report_stat() only flush when force is passed in. Greetings, Andres Freund
Commits
-
Fix initialization of pg_stat_get_lastscan()
- d7744d50a539 16.0 landed
-
pgstat: Track time of the last scan of a relation
- c037471832e1 16.0 landed
-
Have GetCurrentTransactionStopTimestamp() set xactStopTimestamp if unset
- 309b2cf2433d 16.0 landed