Thread: pgsql: Have TRUNCATE update pgstat tuple counters
Have TRUNCATE update pgstat tuple counters This works by keeping a per-subtransaction record of the ins/upd/del counters before the truncate, and then resetting them; this record is useful to return to the previous state in case the truncate is rolled back, either in a subtransaction or whole transaction. The state is propagated upwards as subtransactions commit. When the per-table data is sent to the stats collector, a flag indicates to reset the live/dead counters to zero as well. Catalog version bumped due to the change in pgstat format. Author: Alexander Shulgin Discussion: 1007.1207238291@sss.pgh.pa.us Discussion: 548F7D38.2000401@BlueTreble.com Reviewed-by: Álvaro Herrera, Jim Nasby Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/d42358efb16cc81122c53ffb35ac381b9158e519 Modified Files -------------- src/backend/commands/tablecmds.c | 3 + src/backend/postmaster/pgstat.c | 110 +++++++++++++++++++++++- src/include/pgstat.h | 6 ++ src/test/regress/expected/prepared_xacts.out | 50 +++++++++++ src/test/regress/expected/prepared_xacts_1.out | 53 ++++++++++++ src/test/regress/expected/stats.out | 64 ++++++++++++++ src/test/regress/sql/prepared_xacts.sql | 27 ++++++ src/test/regress/sql/stats.sql | 64 ++++++++++++++ 8 files changed, 374 insertions(+), 3 deletions(-)
Alvaro Herrera <alvherre@alvh.no-ip.org> writes: > Have TRUNCATE update pgstat tuple counters > Catalog version bumped due to the change in pgstat format. I see no catversion.h change here, which is probably a good thing because no such bump should have been made for this change anyway. What *should* have been altered, and was not, was PGSTAT_FILE_FORMAT_ID. Please fix. regards, tom lane
Tom Lane wrote: > Alvaro Herrera <alvherre@alvh.no-ip.org> writes: > > Have TRUNCATE update pgstat tuple counters > > > Catalog version bumped due to the change in pgstat format. > > I see no catversion.h change here, which is probably a good thing because > no such bump should have been made for this change anyway. What *should* > have been altered, and was not, was PGSTAT_FILE_FORMAT_ID. Please fix. Right -- pushed that fix. Now buildfarm member kouprey is failing the added test in prepared_xacts. I am tempted to just remove it rather than try to fix it: there's a 0.5s sleep in there (not enough for sure), but it would be annoying to move it to the stats test which already sleeps however much is necessary, because we would need to add an alternate output for the case when prepared xacts are not enabled in the server. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Alvaro Herrera <alvherre@2ndquadrant.com> writes: > Now buildfarm member kouprey is failing the added test in > prepared_xacts. I am tempted to just remove it rather than try to fix > it: there's a 0.5s sleep in there (not enough for sure), but it would be > annoying to move it to the stats test which already sleeps however much > is necessary, because we would need to add an alternate output for the > case when prepared xacts are not enabled in the server. OK with me. It's not apparent that this behavior has to be memorialized in a regression test. regards, tom lane