pgsql: Have TRUNCATE update pgstat tuple counters

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Have TRUNCATE update pgstat tuple counters
Date: 2015-02-20 15:11:30
Message-ID: E1YOpEo-0004pD-7l@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)1207238291(at)sss(dot)pgh(dot)pa(dot)us
Discussion: 548F7D38(dot)2000401(at)BlueTreble(dot)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(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-02-20 15:23:32 Re: pgsql: Have TRUNCATE update pgstat tuple counters
Previous Message Tom Lane 2015-02-20 07:28:09 pgsql: Some more FLEXIBLE_ARRAY_MEMBER hacking.