Refactor PgStat_TableStatus to new PgStat_RelationStatus

This new structure is split depending on the stats kind it deals with:
- PGSTAT_KIND_RELATION, for tables.
- PGSTAT_KIND_INDEX, for indexes.

This change designs a cleaner barrier for the handling of stats data
related to tables and indexes, by being able to track precisely what are
the counters used by one or the other for pending data.  Using a common
ground for both eases the tracking of Relations in the relcache, with a
structure based on a union separated by stats kind.

The code originally pointed to some counters that may not be used at
all.  For example, indexes have no need for the tracking of
sub-transaction data, still the code implied that these could be touched
for an index.  A consequence is that PgStat_TableXactStatus is not
renamed, as it is not used by indexes.

Some asserts are added as an extra layer of protection to prevent the
update of fields that should not be touched.  find_tabstat_entry() and
find_tabstat_entry_kind() are removed, replaced by a single
find_relstat_entry_kind() able to work for indexes and the rest.

72a6dad1c911 took care of the shared memory and on-disk part of the
split.  This focuses on the pending data part at backend level.

Author: Michael Paquier <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f2ccb8e6c5915617466ccea2abcf2d443d67dab0

Modified Files
--------------
src/backend/utils/activity/pgstat.c          |   4 +-
src/backend/utils/activity/pgstat_index.c    |  30 +--
src/backend/utils/activity/pgstat_relation.c | 315 ++++++++++++++-------------
src/backend/utils/adt/pgstatfuncs.c          |  13 +-
src/backend/utils/cache/relcache.c           |   2 +-
src/include/pgstat.h                         | 112 +++++++---
src/include/utils/pgstat_internal.h          |   2 +-
src/include/utils/rel.h                      |   2 +-
src/tools/pgindent/typedefs.list             |   3 +-
9 files changed, 282 insertions(+), 201 deletions(-)

Reply via email to