diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/activity/pgstat_relation.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c index a78b8d2450f..4f97d2f1d9c 100644 --- a/src/backend/utils/activity/pgstat_relation.c +++ b/src/backend/utils/activity/pgstat_relation.c @@ -96,6 +96,38 @@ static HTAB *pgStatTabHash = NULL; /* + * Copy stats between relations. This is used for things like REINDEX + * CONCURRENTLY. + */ +void +pgstat_copy_relation_stats(Relation dst, Relation src) +{ + PgStat_StatTabEntry *srcstats; + + srcstats = pgstat_fetch_stat_tabentry(RelationGetRelid(src)); + + if (!srcstats) + return; + + if (pgstat_relation_should_count(dst)) + { + /* + * XXX: temporarily this does not actually quite do what the name + * says, and just copy index related fields. A subsequent commit will + * do more. + */ + + dst->pgstat_info->t_counts.t_numscans = srcstats->numscans; + dst->pgstat_info->t_counts.t_tuples_returned = srcstats->tuples_returned; + dst->pgstat_info->t_counts.t_tuples_fetched = srcstats->tuples_fetched; + dst->pgstat_info->t_counts.t_blocks_fetched = srcstats->blocks_fetched; + dst->pgstat_info->t_counts.t_blocks_hit = srcstats->blocks_hit; + + /* the data will be sent by the next pgstat_report_stat() call */ + } +} + +/* * Initialize a relcache entry to count access statistics. * Called whenever a relation is opened. * |