Remove nonmeaningful prefixes in PgStat_* fields
Hi hackers,
Please find attached a patch to $SUBJECT.
It is a preliminary patch for [1]/messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com.
The main ideas are: 1) to have consistent naming between the pg_stat_get*() functions
and their associated counters and 2) to define the new macros in [1]/messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com the same way as it
has been done in 8018ffbf58 (aka not using the prefixes in the macros).
Looking forward to your feedback,
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
[1]: /messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com
Attachments:
v1-0001-remove_nonmeaningful_prefixes.patchtext/plain; charset=UTF-8; name=v1-0001-remove_nonmeaningful_prefixes.patchDownload
diff --git a/src/backend/utils/activity/pgstat_function.c b/src/backend/utils/activity/pgstat_function.c
index 6139a27fee..edf79ebc8f 100644
--- a/src/backend/utils/activity/pgstat_function.c
+++ b/src/backend/utils/activity/pgstat_function.c
@@ -121,16 +121,16 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
pending = entry_ref->pending;
- fcu->fs = &pending->f_counts;
+ fcu->fs = &pending->counts;
/* save stats for this function, later used to compensate for recursion */
- fcu->save_f_total_time = pending->f_counts.f_total_time;
+ fcu->save_total_time = pending->counts.total_time;
/* save current backend-wide total time */
fcu->save_total = total_func_time;
/* get clock time as of function start */
- INSTR_TIME_SET_CURRENT(fcu->f_start);
+ INSTR_TIME_SET_CURRENT(fcu->start);
}
/*
@@ -146,41 +146,41 @@ void
pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
{
PgStat_FunctionCounts *fs = fcu->fs;
- instr_time f_total;
- instr_time f_others;
- instr_time f_self;
+ instr_time total;
+ instr_time others;
+ instr_time self;
/* stats not wanted? */
if (fs == NULL)
return;
/* total elapsed time in this function call */
- INSTR_TIME_SET_CURRENT(f_total);
- INSTR_TIME_SUBTRACT(f_total, fcu->f_start);
+ INSTR_TIME_SET_CURRENT(total);
+ INSTR_TIME_SUBTRACT(total, fcu->start);
/* self usage: elapsed minus anything already charged to other calls */
- f_others = total_func_time;
- INSTR_TIME_SUBTRACT(f_others, fcu->save_total);
- f_self = f_total;
- INSTR_TIME_SUBTRACT(f_self, f_others);
+ others = total_func_time;
+ INSTR_TIME_SUBTRACT(others, fcu->save_total);
+ self = total;
+ INSTR_TIME_SUBTRACT(self, others);
/* update backend-wide total time */
- INSTR_TIME_ADD(total_func_time, f_self);
+ INSTR_TIME_ADD(total_func_time, self);
/*
- * Compute the new f_total_time as the total elapsed time added to the
- * pre-call value of f_total_time. This is necessary to avoid
+ * Compute the new total_time as the total elapsed time added to the
+ * pre-call value of total_time. This is necessary to avoid
* double-counting any time taken by recursive calls of myself. (We do
* not need any similar kluge for self time, since that already excludes
* any recursive calls.)
*/
- INSTR_TIME_ADD(f_total, fcu->save_f_total_time);
+ INSTR_TIME_ADD(total, fcu->save_total_time);
/* update counters in function stats table */
if (finalize)
- fs->f_numcalls++;
- fs->f_total_time = f_total;
- INSTR_TIME_ADD(fs->f_self_time, f_self);
+ fs->numcalls++;
+ fs->total_time = total;
+ INSTR_TIME_ADD(fs->self_time, self);
}
/*
@@ -203,11 +203,11 @@ pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
if (!pgstat_lock_entry(entry_ref, nowait))
return false;
- shfuncent->stats.f_numcalls += localent->f_counts.f_numcalls;
- shfuncent->stats.f_total_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_counts.f_total_time);
- shfuncent->stats.f_self_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_counts.f_self_time);
+ shfuncent->stats.numcalls += localent->counts.numcalls;
+ shfuncent->stats.total_time +=
+ INSTR_TIME_GET_MICROSEC(localent->counts.total_time);
+ shfuncent->stats.self_time +=
+ INSTR_TIME_GET_MICROSEC(localent->counts.self_time);
pgstat_unlock_entry(entry_ref);
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index 1730425de1..737ec525b3 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -38,9 +38,9 @@ typedef struct TwoPhasePgStatRecord
PgStat_Counter inserted_pre_truncdrop;
PgStat_Counter updated_pre_truncdrop;
PgStat_Counter deleted_pre_truncdrop;
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
- bool t_truncdropped; /* was the relation truncated/dropped? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
+ bool truncdropped; /* was the relation truncated/dropped? */
} TwoPhasePgStatRecord;
@@ -302,7 +302,7 @@ pgstat_report_analyze(Relation rel,
deadtuples -= trans->tuples_updated + trans->tuples_deleted;
}
/* count stuff inserted by already-aborted subxacts, too */
- deadtuples -= rel->pgstat_info->t_counts.t_delta_dead_tuples;
+ deadtuples -= rel->pgstat_info->counts.delta_dead_tuples;
/* Since ANALYZE's counts are estimates, we could have underflowed */
livetuples = Max(livetuples, 0);
deadtuples = Max(deadtuples, 0);
@@ -373,7 +373,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
/* t_tuples_hot_updated is nontransactional, so just advance it */
if (hot)
- pgstat_info->t_counts.t_tuples_hot_updated++;
+ pgstat_info->counts.tuples_hot_updated++;
}
}
@@ -425,7 +425,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
{
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
- pgstat_info->t_counts.t_delta_dead_tuples -= delta;
+ pgstat_info->counts.delta_dead_tuples -= delta;
}
}
@@ -501,33 +501,33 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
if (!isCommit)
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
if (isCommit)
{
- tabstat->t_counts.t_truncdropped = trans->truncdropped;
+ tabstat->counts.truncdropped = trans->truncdropped;
if (trans->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- tabstat->t_counts.t_delta_live_tuples = 0;
- tabstat->t_counts.t_delta_dead_tuples = 0;
+ tabstat->counts.delta_live_tuples = 0;
+ tabstat->counts.delta_dead_tuples = 0;
}
/* insert adds a live tuple, delete removes one */
- tabstat->t_counts.t_delta_live_tuples +=
+ tabstat->counts.delta_live_tuples +=
trans->tuples_inserted - trans->tuples_deleted;
/* update and delete each create a dead tuple */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_updated + trans->tuples_deleted;
/* insert, update, delete each count as one change event */
- tabstat->t_counts.t_changed_tuples +=
+ tabstat->counts.changed_tuples +=
trans->tuples_inserted + trans->tuples_updated +
trans->tuples_deleted;
}
else
{
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
/* an aborted xact generates no changed_tuple events */
}
@@ -607,11 +607,11 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
/* first restore values obliterated by truncate/drop */
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
tabstat->trans = trans->upper;
pfree(trans);
@@ -644,9 +644,9 @@ AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
record.inserted_pre_truncdrop = trans->inserted_pre_truncdrop;
record.updated_pre_truncdrop = trans->updated_pre_truncdrop;
record.deleted_pre_truncdrop = trans->deleted_pre_truncdrop;
- record.t_id = tabstat->t_id;
- record.t_shared = tabstat->t_shared;
- record.t_truncdropped = trans->truncdropped;
+ record.id = tabstat->id;
+ record.shared = tabstat->shared;
+ record.truncdropped = trans->truncdropped;
RegisterTwoPhaseRecord(TWOPHASE_RM_PGSTAT_ID, 0,
&record, sizeof(TwoPhasePgStatRecord));
@@ -688,24 +688,24 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, commit case */
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_truncdropped = rec->t_truncdropped;
- if (rec->t_truncdropped)
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.truncdropped = rec->truncdropped;
+ if (rec->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- pgstat_info->t_counts.t_delta_live_tuples = 0;
- pgstat_info->t_counts.t_delta_dead_tuples = 0;
+ pgstat_info->counts.delta_live_tuples = 0;
+ pgstat_info->counts.delta_dead_tuples = 0;
}
- pgstat_info->t_counts.t_delta_live_tuples +=
+ pgstat_info->counts.delta_live_tuples +=
rec->tuples_inserted - rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_updated + rec->tuples_deleted;
- pgstat_info->t_counts.t_changed_tuples +=
+ pgstat_info->counts.changed_tuples +=
rec->tuples_inserted + rec->tuples_updated +
rec->tuples_deleted;
}
@@ -724,19 +724,19 @@ pgstat_twophase_postabort(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, abort case */
- if (rec->t_truncdropped)
+ if (rec->truncdropped)
{
rec->tuples_inserted = rec->inserted_pre_truncdrop;
rec->tuples_updated = rec->updated_pre_truncdrop;
rec->tuples_deleted = rec->deleted_pre_truncdrop;
}
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_inserted + rec->tuples_updated;
}
@@ -767,7 +767,7 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
* Ignore entries that didn't accumulate any actual counts, such as
* indexes that were opened by the planner but not used.
*/
- if (memcmp(&lstats->t_counts, &all_zeroes,
+ if (memcmp(&lstats->counts, &all_zeroes,
sizeof(PgStat_TableCounts)) == 0)
{
return true;
@@ -779,36 +779,36 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* add the values to the shared entry. */
tabentry = &shtabstats->stats;
- tabentry->numscans += lstats->t_counts.t_numscans;
- if (lstats->t_counts.t_numscans)
+ tabentry->numscans += lstats->counts.numscans;
+ if (lstats->counts.numscans)
{
TimestampTz t = GetCurrentTransactionStopTimestamp();
if (t > tabentry->lastscan)
tabentry->lastscan = t;
}
- tabentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- tabentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- tabentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- tabentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- tabentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- tabentry->tuples_hot_updated += lstats->t_counts.t_tuples_hot_updated;
+ tabentry->tuples_returned += lstats->counts.tuples_returned;
+ tabentry->tuples_fetched += lstats->counts.tuples_fetched;
+ tabentry->tuples_inserted += lstats->counts.tuples_inserted;
+ tabentry->tuples_updated += lstats->counts.tuples_updated;
+ tabentry->tuples_deleted += lstats->counts.tuples_deleted;
+ tabentry->tuples_hot_updated += lstats->counts.tuples_hot_updated;
/*
* If table was truncated/dropped, first reset the live/dead counters.
*/
- if (lstats->t_counts.t_truncdropped)
+ if (lstats->counts.truncdropped)
{
tabentry->live_tuples = 0;
tabentry->dead_tuples = 0;
tabentry->ins_since_vacuum = 0;
}
- tabentry->live_tuples += lstats->t_counts.t_delta_live_tuples;
- tabentry->dead_tuples += lstats->t_counts.t_delta_dead_tuples;
- tabentry->mod_since_analyze += lstats->t_counts.t_changed_tuples;
- tabentry->ins_since_vacuum += lstats->t_counts.t_tuples_inserted;
- tabentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- tabentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ tabentry->live_tuples += lstats->counts.delta_live_tuples;
+ tabentry->dead_tuples += lstats->counts.delta_dead_tuples;
+ tabentry->mod_since_analyze += lstats->counts.changed_tuples;
+ tabentry->ins_since_vacuum += lstats->counts.tuples_inserted;
+ tabentry->blocks_fetched += lstats->counts.blocks_fetched;
+ tabentry->blocks_hit += lstats->counts.blocks_hit;
/* Clamp live_tuples in case of negative delta_live_tuples */
tabentry->live_tuples = Max(tabentry->live_tuples, 0);
@@ -819,13 +819,13 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* The entry was successfully flushed, add the same to database stats */
dbentry = pgstat_prep_database_pending(dboid);
- dbentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- dbentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- dbentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- dbentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- dbentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- dbentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- dbentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ dbentry->tuples_returned += lstats->counts.tuples_returned;
+ dbentry->tuples_fetched += lstats->counts.tuples_fetched;
+ dbentry->tuples_inserted += lstats->counts.tuples_inserted;
+ dbentry->tuples_updated += lstats->counts.tuples_updated;
+ dbentry->tuples_deleted += lstats->counts.tuples_deleted;
+ dbentry->blocks_fetched += lstats->counts.blocks_fetched;
+ dbentry->blocks_hit += lstats->counts.blocks_hit;
return true;
}
@@ -853,8 +853,8 @@ pgstat_prep_relation_pending(Oid rel_id, bool isshared)
isshared ? InvalidOid : MyDatabaseId,
rel_id, NULL);
pending = entry_ref->pending;
- pending->t_id = rel_id;
- pending->t_shared = isshared;
+ pending->id = rel_id;
+ pending->shared = isshared;
return pending;
}
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 6cddd74aa7..631c1415b4 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -145,7 +145,7 @@ pg_stat_get_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_numcalls);
+ PG_RETURN_INT64(funcentry->numcalls);
}
Datum
@@ -157,7 +157,7 @@ pg_stat_get_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_total_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->total_time) / 1000.0);
}
Datum
@@ -169,7 +169,7 @@ pg_stat_get_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_self_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->self_time) / 1000.0);
}
Datum
@@ -1355,7 +1355,7 @@ pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_numscans);
+ result = (int64) (tabentry->counts.numscans);
PG_RETURN_INT64(result);
}
@@ -1370,7 +1370,7 @@ pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_returned);
+ result = (int64) (tabentry->counts.tuples_returned);
PG_RETURN_INT64(result);
}
@@ -1385,7 +1385,7 @@ pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_fetched);
+ result = (int64) (tabentry->counts.tuples_fetched);
PG_RETURN_INT64(result);
}
@@ -1402,7 +1402,7 @@ pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_inserted;
+ result = tabentry->counts.tuples_inserted;
/* live subtransactions' counts aren't in t_tuples_inserted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_inserted;
@@ -1423,7 +1423,7 @@ pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_updated;
+ result = tabentry->counts.tuples_updated;
/* live subtransactions' counts aren't in t_tuples_updated yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_updated;
@@ -1444,7 +1444,7 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_deleted;
+ result = tabentry->counts.tuples_deleted;
/* live subtransactions' counts aren't in t_tuples_deleted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_deleted;
@@ -1463,7 +1463,7 @@ pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_hot_updated);
+ result = (int64) (tabentry->counts.tuples_hot_updated);
PG_RETURN_INT64(result);
}
@@ -1478,7 +1478,7 @@ pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_fetched);
+ result = (int64) (tabentry->counts.blocks_fetched);
PG_RETURN_INT64(result);
}
@@ -1493,7 +1493,7 @@ pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_hit);
+ result = (int64) (tabentry->counts.blocks_hit);
PG_RETURN_INT64(result);
}
@@ -1506,7 +1506,7 @@ pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_counts.f_numcalls);
+ PG_RETURN_INT64(funcentry->counts.numcalls);
}
Datum
@@ -1517,7 +1517,7 @@ pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_total_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->counts.total_time));
}
Datum
@@ -1528,7 +1528,7 @@ pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_counts.f_self_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->counts.self_time));
}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index d3e965d744..b225039792 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -105,9 +105,9 @@ typedef int64 PgStat_Counter;
*/
typedef struct PgStat_FunctionCounts
{
- PgStat_Counter f_numcalls;
- instr_time f_total_time;
- instr_time f_self_time;
+ PgStat_Counter numcalls;
+ instr_time total_time;
+ instr_time self_time;
} PgStat_FunctionCounts;
/* ----------
@@ -116,7 +116,7 @@ typedef struct PgStat_FunctionCounts
*/
typedef struct PgStat_BackendFunctionEntry
{
- PgStat_FunctionCounts f_counts;
+ PgStat_FunctionCounts counts;
} PgStat_BackendFunctionEntry;
/*
@@ -128,11 +128,11 @@ typedef struct PgStat_FunctionCallUsage
/* NULL means we are not tracking the current function call */
PgStat_FunctionCounts *fs;
/* Total time previously charged to function, as of function start */
- instr_time save_f_total_time;
+ instr_time save_total_time;
/* Backend-wide total time as of function start */
instr_time save_total;
/* system clock as of function start */
- instr_time f_start;
+ instr_time start;
} PgStat_FunctionCallUsage;
/* ----------
@@ -167,23 +167,23 @@ typedef struct PgStat_BackendSubEntry
*/
typedef struct PgStat_TableCounts
{
- PgStat_Counter t_numscans;
+ PgStat_Counter numscans;
- PgStat_Counter t_tuples_returned;
- PgStat_Counter t_tuples_fetched;
+ PgStat_Counter tuples_returned;
+ PgStat_Counter tuples_fetched;
- PgStat_Counter t_tuples_inserted;
- PgStat_Counter t_tuples_updated;
- PgStat_Counter t_tuples_deleted;
- PgStat_Counter t_tuples_hot_updated;
- bool t_truncdropped;
+ PgStat_Counter tuples_inserted;
+ PgStat_Counter tuples_updated;
+ PgStat_Counter tuples_deleted;
+ PgStat_Counter tuples_hot_updated;
+ bool truncdropped;
- PgStat_Counter t_delta_live_tuples;
- PgStat_Counter t_delta_dead_tuples;
- PgStat_Counter t_changed_tuples;
+ PgStat_Counter delta_live_tuples;
+ PgStat_Counter delta_dead_tuples;
+ PgStat_Counter changed_tuples;
- PgStat_Counter t_blocks_fetched;
- PgStat_Counter t_blocks_hit;
+ PgStat_Counter blocks_fetched;
+ PgStat_Counter blocks_hit;
} PgStat_TableCounts;
/* ----------
@@ -203,10 +203,10 @@ typedef struct PgStat_TableCounts
*/
typedef struct PgStat_TableStatus
{
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
- PgStat_TableCounts t_counts; /* event counts to be sent */
+ PgStat_TableCounts counts; /* event counts to be sent */
Relation relation; /* rel that is using this entry */
} PgStat_TableStatus;
@@ -313,10 +313,10 @@ typedef struct PgStat_StatDBEntry
typedef struct PgStat_StatFuncEntry
{
- PgStat_Counter f_numcalls;
+ PgStat_Counter numcalls;
- PgStat_Counter f_total_time; /* times in microseconds */
- PgStat_Counter f_self_time;
+ PgStat_Counter total_time; /* times in microseconds */
+ PgStat_Counter self_time;
} PgStat_StatFuncEntry;
typedef struct PgStat_StatReplSlotEntry
@@ -525,37 +525,37 @@ extern void pgstat_report_analyze(Relation rel,
#define pgstat_count_heap_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_heap_getnext(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned++; \
+ (rel)->pgstat_info->counts.tuples_returned++; \
} while (0)
#define pgstat_count_heap_fetch(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_fetched++; \
+ (rel)->pgstat_info->counts.tuples_fetched++; \
} while (0)
#define pgstat_count_index_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_index_tuples(rel, n) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
+ (rel)->pgstat_info->counts.tuples_returned += (n); \
} while (0)
#define pgstat_count_buffer_read(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_fetched++; \
+ (rel)->pgstat_info->counts.blocks_fetched++; \
} while (0)
#define pgstat_count_buffer_hit(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_hit++; \
+ (rel)->pgstat_info->counts.blocks_hit++; \
} while (0)
extern void pgstat_count_heap_insert(Relation rel, PgStat_Counter n);
On 2023-Jan-12, Drouvot, Bertrand wrote:
Please find attached a patch to $SUBJECT.
It is a preliminary patch for [1].
The main ideas are: 1) to have consistent naming between the pg_stat_get*() functions
and their associated counters and 2) to define the new macros in [1] the same way as it
has been done in 8018ffbf58 (aka not using the prefixes in the macros).
I don't like this at all. With these prefixes in place, it's much more
likely that you'll be able to grep the whole source tree and not run
into tons of false positives. If you remove them, that tends to be not
very workable. If we use these commits as precedent for expanding this
sort of renaming across the tree, we'll soon end up with a very
grep-unfriendly code base.
The PGSTAT_ACCUM_DBCOUNT and PG_STAT_GET_DBENTRY macros are just one
argument away from being able to generate the variable name including
the prefix, anyway. I don't know why we had to rename everything in
order to do 8018ffbf5895, and if I had my druthers, we'd undo that.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
I don't like this at all. With these prefixes in place, it's much more
likely that you'll be able to grep the whole source tree and not run
into tons of false positives. If you remove them, that tends to be not
very workable. If we use these commits as precedent for expanding this
sort of renaming across the tree, we'll soon end up with a very
grep-unfriendly code base.
+1, that was my immediate fear as well.
regards, tom lane
Hi,
On 2023-01-12 18:12:52 +0100, Alvaro Herrera wrote:
On 2023-Jan-12, Drouvot, Bertrand wrote:
Please find attached a patch to $SUBJECT.
It is a preliminary patch for [1].
The main ideas are: 1) to have consistent naming between the pg_stat_get*() functions
and their associated counters and 2) to define the new macros in [1] the same way as it
has been done in 8018ffbf58 (aka not using the prefixes in the macros).I don't like this at all. With these prefixes in place, it's much more
likely that you'll be able to grep the whole source tree and not run
into tons of false positives. If you remove them, that tends to be not
very workable. If we use these commits as precedent for expanding this
sort of renaming across the tree, we'll soon end up with a very
grep-unfriendly code base.
The problem with that is that the prefixes are used completely inconsistently
- and have been for a long time. And not just between the different type of
stats. Compare e.g. PgStat_TableCounts with PgStat_TableXactStatus and
PgStat_StatTabEntry. Whereas PgStat_FunctionCounts and PgStat_StatFuncEntry
both use it. Right now there's no way to remember where to add the t_ prefix,
and where not.
Imo the reason to rename here isn't to abolish prefixes, it's to be halfway
consistent within closeby code. And the code overwhelmingly doesn't use the
prefixes.
Greetings,
Andres Freund
On Thu, Jan 12, 2023 at 10:07:33AM -0800, Andres Freund wrote:
The problem with that is that the prefixes are used completely inconsistently
- and have been for a long time. And not just between the different type of
stats. Compare e.g. PgStat_TableCounts with PgStat_TableXactStatus and
PgStat_StatTabEntry. Whereas PgStat_FunctionCounts and PgStat_StatFuncEntry
both use it. Right now there's no way to remember where to add the t_ prefix,
and where not.Imo the reason to rename here isn't to abolish prefixes, it's to be halfway
consistent within closeby code. And the code overwhelmingly doesn't use the
prefixes.
Reading through the patch, two things are done, basically:
- Remove the prefix "t_" from the fields related to table stats.
- Remove the prefix "f_" from the fields related to function stats.
And FWIW, with my recent lookups at the pgstat code, I'd like to think
that removing the prefixes is actually an improvement in consistency.
It will help in refactoring this code to use more macros, reducing its
size, as well.
So, the code paths where the structures are updated are pretty short
so you know to what they refer to. And that's even more OK because
now the objects are split into their own files, so you know what you
are dealing with even if the individual variable names are more
common. That's for pgstat_relation.c and pgstat_function.c, first.
The second part of the changes involves pgstatfuncs.c, where all the
objects are grouped in a single file. We don't lose any information
here, either, as the code updated deals with a "tabentry" or
"funcentry". There is a small part in pgstat.h where a few macros
have their fields renamed, where we manipulate a "rel", so that looks
rather clear to me what we are dealing with, IMO.
/* Total time previously charged to function, as of function start */
- instr_time save_f_total_time;
+ instr_time save_total_time;
I have something to say about this one, though.. I find this change a
bit confusing. It may be better kept as it is, or I think that we'd
better rename also "save_total" and "start" to reflect in a better way
what they do, because removing "f_" reduces the meaning of the field
with the two others in the same structure.
--
Michael
Hi,
On 3/20/23 8:32 AM, Michael Paquier wrote:
/* Total time previously charged to function, as of function start */ - instr_time save_f_total_time; + instr_time save_total_time; I have something to say about this one, though.. I find this change a bit confusing. It may be better kept as it is, or I think that we'd better rename also "save_total" and "start" to reflect in a better way what they do, because removing "f_" reduces the meaning of the field with the two others in the same structure.
Thanks for looking at it!
Good point and keeping it as it is currently would not
affect the work that is/will be done in [1]/messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com.
So, please find attached V2 attached taking this comment into account.
[1]: /messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachments:
v2-0001-remove_nonmeaningful_prefixes.patchtext/plain; charset=UTF-8; name=v2-0001-remove_nonmeaningful_prefixes.patchDownload
diff --git a/src/backend/utils/activity/pgstat_function.c b/src/backend/utils/activity/pgstat_function.c
index 0fdcefb783..79e781167b 100644
--- a/src/backend/utils/activity/pgstat_function.c
+++ b/src/backend/utils/activity/pgstat_function.c
@@ -124,13 +124,13 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
fcu->fs = pending;
/* save stats for this function, later used to compensate for recursion */
- fcu->save_f_total_time = pending->f_total_time;
+ fcu->save_f_total_time = pending->total_time;
/* save current backend-wide total time */
fcu->save_total = total_func_time;
/* get clock time as of function start */
- INSTR_TIME_SET_CURRENT(fcu->f_start);
+ INSTR_TIME_SET_CURRENT(fcu->start);
}
/*
@@ -146,41 +146,41 @@ void
pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
{
PgStat_FunctionCounts *fs = fcu->fs;
- instr_time f_total;
- instr_time f_others;
- instr_time f_self;
+ instr_time total;
+ instr_time others;
+ instr_time self;
/* stats not wanted? */
if (fs == NULL)
return;
/* total elapsed time in this function call */
- INSTR_TIME_SET_CURRENT(f_total);
- INSTR_TIME_SUBTRACT(f_total, fcu->f_start);
+ INSTR_TIME_SET_CURRENT(total);
+ INSTR_TIME_SUBTRACT(total, fcu->start);
/* self usage: elapsed minus anything already charged to other calls */
- f_others = total_func_time;
- INSTR_TIME_SUBTRACT(f_others, fcu->save_total);
- f_self = f_total;
- INSTR_TIME_SUBTRACT(f_self, f_others);
+ others = total_func_time;
+ INSTR_TIME_SUBTRACT(others, fcu->save_total);
+ self = total;
+ INSTR_TIME_SUBTRACT(self, others);
/* update backend-wide total time */
- INSTR_TIME_ADD(total_func_time, f_self);
+ INSTR_TIME_ADD(total_func_time, self);
/*
- * Compute the new f_total_time as the total elapsed time added to the
- * pre-call value of f_total_time. This is necessary to avoid
+ * Compute the new total_time as the total elapsed time added to the
+ * pre-call value of total_time. This is necessary to avoid
* double-counting any time taken by recursive calls of myself. (We do
* not need any similar kluge for self time, since that already excludes
* any recursive calls.)
*/
- INSTR_TIME_ADD(f_total, fcu->save_f_total_time);
+ INSTR_TIME_ADD(total, fcu->save_f_total_time);
/* update counters in function stats table */
if (finalize)
- fs->f_numcalls++;
- fs->f_total_time = f_total;
- INSTR_TIME_ADD(fs->f_self_time, f_self);
+ fs->numcalls++;
+ fs->total_time = total;
+ INSTR_TIME_ADD(fs->self_time, self);
}
/*
@@ -203,11 +203,11 @@ pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
if (!pgstat_lock_entry(entry_ref, nowait))
return false;
- shfuncent->stats.f_numcalls += localent->f_numcalls;
- shfuncent->stats.f_total_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_total_time);
- shfuncent->stats.f_self_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_self_time);
+ shfuncent->stats.numcalls += localent->numcalls;
+ shfuncent->stats.total_time +=
+ INSTR_TIME_GET_MICROSEC(localent->total_time);
+ shfuncent->stats.self_time +=
+ INSTR_TIME_GET_MICROSEC(localent->self_time);
pgstat_unlock_entry(entry_ref);
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index f793ac1516..85c24e6869 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -38,9 +38,9 @@ typedef struct TwoPhasePgStatRecord
PgStat_Counter inserted_pre_truncdrop;
PgStat_Counter updated_pre_truncdrop;
PgStat_Counter deleted_pre_truncdrop;
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
- bool t_truncdropped; /* was the relation truncated/dropped? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
+ bool truncdropped; /* was the relation truncated/dropped? */
} TwoPhasePgStatRecord;
@@ -310,7 +310,7 @@ pgstat_report_analyze(Relation rel,
deadtuples -= trans->tuples_updated + trans->tuples_deleted;
}
/* count stuff inserted by already-aborted subxacts, too */
- deadtuples -= rel->pgstat_info->t_counts.t_delta_dead_tuples;
+ deadtuples -= rel->pgstat_info->counts.delta_dead_tuples;
/* Since ANALYZE's counts are estimates, we could have underflowed */
livetuples = Max(livetuples, 0);
deadtuples = Max(deadtuples, 0);
@@ -384,7 +384,7 @@ pgstat_count_heap_update(Relation rel, bool hot)
/* t_tuples_hot_updated is nontransactional, so just advance it */
if (hot)
- pgstat_info->t_counts.t_tuples_hot_updated++;
+ pgstat_info->counts.tuples_hot_updated++;
}
}
@@ -436,7 +436,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
{
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
- pgstat_info->t_counts.t_delta_dead_tuples -= delta;
+ pgstat_info->counts.delta_dead_tuples -= delta;
}
}
@@ -512,33 +512,33 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
if (!isCommit)
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
if (isCommit)
{
- tabstat->t_counts.t_truncdropped = trans->truncdropped;
+ tabstat->counts.truncdropped = trans->truncdropped;
if (trans->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- tabstat->t_counts.t_delta_live_tuples = 0;
- tabstat->t_counts.t_delta_dead_tuples = 0;
+ tabstat->counts.delta_live_tuples = 0;
+ tabstat->counts.delta_dead_tuples = 0;
}
/* insert adds a live tuple, delete removes one */
- tabstat->t_counts.t_delta_live_tuples +=
+ tabstat->counts.delta_live_tuples +=
trans->tuples_inserted - trans->tuples_deleted;
/* update and delete each create a dead tuple */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_updated + trans->tuples_deleted;
/* insert, update, delete each count as one change event */
- tabstat->t_counts.t_changed_tuples +=
+ tabstat->counts.changed_tuples +=
trans->tuples_inserted + trans->tuples_updated +
trans->tuples_deleted;
}
else
{
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
/* an aborted xact generates no changed_tuple events */
}
@@ -618,11 +618,11 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
/* first restore values obliterated by truncate/drop */
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
tabstat->trans = trans->upper;
pfree(trans);
@@ -655,9 +655,9 @@ AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
record.inserted_pre_truncdrop = trans->inserted_pre_truncdrop;
record.updated_pre_truncdrop = trans->updated_pre_truncdrop;
record.deleted_pre_truncdrop = trans->deleted_pre_truncdrop;
- record.t_id = tabstat->t_id;
- record.t_shared = tabstat->t_shared;
- record.t_truncdropped = trans->truncdropped;
+ record.id = tabstat->id;
+ record.shared = tabstat->shared;
+ record.truncdropped = trans->truncdropped;
RegisterTwoPhaseRecord(TWOPHASE_RM_PGSTAT_ID, 0,
&record, sizeof(TwoPhasePgStatRecord));
@@ -699,24 +699,24 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, commit case */
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_truncdropped = rec->t_truncdropped;
- if (rec->t_truncdropped)
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.truncdropped = rec->truncdropped;
+ if (rec->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- pgstat_info->t_counts.t_delta_live_tuples = 0;
- pgstat_info->t_counts.t_delta_dead_tuples = 0;
+ pgstat_info->counts.delta_live_tuples = 0;
+ pgstat_info->counts.delta_dead_tuples = 0;
}
- pgstat_info->t_counts.t_delta_live_tuples +=
+ pgstat_info->counts.delta_live_tuples +=
rec->tuples_inserted - rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_updated + rec->tuples_deleted;
- pgstat_info->t_counts.t_changed_tuples +=
+ pgstat_info->counts.changed_tuples +=
rec->tuples_inserted + rec->tuples_updated +
rec->tuples_deleted;
}
@@ -735,19 +735,19 @@ pgstat_twophase_postabort(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, abort case */
- if (rec->t_truncdropped)
+ if (rec->truncdropped)
{
rec->tuples_inserted = rec->inserted_pre_truncdrop;
rec->tuples_updated = rec->updated_pre_truncdrop;
rec->tuples_deleted = rec->deleted_pre_truncdrop;
}
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_inserted + rec->tuples_updated;
}
@@ -778,7 +778,7 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
* Ignore entries that didn't accumulate any actual counts, such as
* indexes that were opened by the planner but not used.
*/
- if (memcmp(&lstats->t_counts, &all_zeroes,
+ if (memcmp(&lstats->counts, &all_zeroes,
sizeof(PgStat_TableCounts)) == 0)
{
return true;
@@ -790,37 +790,37 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* add the values to the shared entry. */
tabentry = &shtabstats->stats;
- tabentry->numscans += lstats->t_counts.t_numscans;
- if (lstats->t_counts.t_numscans)
+ tabentry->numscans += lstats->counts.numscans;
+ if (lstats->counts.numscans)
{
TimestampTz t = GetCurrentTransactionStopTimestamp();
if (t > tabentry->lastscan)
tabentry->lastscan = t;
}
- tabentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- tabentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- tabentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- tabentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- tabentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- tabentry->tuples_hot_updated += lstats->t_counts.t_tuples_hot_updated;
+ tabentry->tuples_returned += lstats->counts.tuples_returned;
+ tabentry->tuples_fetched += lstats->counts.tuples_fetched;
+ tabentry->tuples_inserted += lstats->counts.tuples_inserted;
+ tabentry->tuples_updated += lstats->counts.tuples_updated;
+ tabentry->tuples_deleted += lstats->counts.tuples_deleted;
+ tabentry->tuples_hot_updated += lstats->counts.tuples_hot_updated;
/*
* If table was truncated/dropped, first reset the live/dead counters.
*/
- if (lstats->t_counts.t_truncdropped)
+ if (lstats->counts.truncdropped)
{
tabentry->live_tuples = 0;
tabentry->dead_tuples = 0;
tabentry->ins_since_vacuum = 0;
}
- tabentry->live_tuples += lstats->t_counts.t_delta_live_tuples;
- tabentry->dead_tuples += lstats->t_counts.t_delta_dead_tuples;
- tabentry->mod_since_analyze += lstats->t_counts.t_changed_tuples;
- tabentry->ins_since_vacuum += lstats->t_counts.t_tuples_inserted;
- tabentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- tabentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ tabentry->live_tuples += lstats->counts.delta_live_tuples;
+ tabentry->dead_tuples += lstats->counts.delta_dead_tuples;
+ tabentry->mod_since_analyze += lstats->counts.changed_tuples;
+ tabentry->ins_since_vacuum += lstats->counts.tuples_inserted;
+ tabentry->blocks_fetched += lstats->counts.blocks_fetched;
+ tabentry->blocks_hit += lstats->counts.blocks_hit;
/* Clamp live_tuples in case of negative delta_live_tuples */
tabentry->live_tuples = Max(tabentry->live_tuples, 0);
@@ -831,13 +831,13 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* The entry was successfully flushed, add the same to database stats */
dbentry = pgstat_prep_database_pending(dboid);
- dbentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- dbentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- dbentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- dbentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- dbentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- dbentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- dbentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ dbentry->tuples_returned += lstats->counts.tuples_returned;
+ dbentry->tuples_fetched += lstats->counts.tuples_fetched;
+ dbentry->tuples_inserted += lstats->counts.tuples_inserted;
+ dbentry->tuples_updated += lstats->counts.tuples_updated;
+ dbentry->tuples_deleted += lstats->counts.tuples_deleted;
+ dbentry->blocks_fetched += lstats->counts.blocks_fetched;
+ dbentry->blocks_hit += lstats->counts.blocks_hit;
return true;
}
@@ -865,8 +865,8 @@ pgstat_prep_relation_pending(Oid rel_id, bool isshared)
isshared ? InvalidOid : MyDatabaseId,
rel_id, NULL);
pending = entry_ref->pending;
- pending->t_id = rel_id;
- pending->t_shared = isshared;
+ pending->id = rel_id;
+ pending->shared = isshared;
return pending;
}
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 35c6d46555..4f21fb2dc2 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -146,7 +146,7 @@ pg_stat_get_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_numcalls);
+ PG_RETURN_INT64(funcentry->numcalls);
}
Datum
@@ -158,7 +158,7 @@ pg_stat_get_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_total_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->total_time) / 1000.0);
}
Datum
@@ -170,7 +170,7 @@ pg_stat_get_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_self_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->self_time) / 1000.0);
}
Datum
@@ -1505,7 +1505,7 @@ pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_numscans);
+ result = (int64) (tabentry->counts.numscans);
PG_RETURN_INT64(result);
}
@@ -1520,7 +1520,7 @@ pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_returned);
+ result = (int64) (tabentry->counts.tuples_returned);
PG_RETURN_INT64(result);
}
@@ -1535,7 +1535,7 @@ pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_fetched);
+ result = (int64) (tabentry->counts.tuples_fetched);
PG_RETURN_INT64(result);
}
@@ -1552,7 +1552,7 @@ pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_inserted;
+ result = tabentry->counts.tuples_inserted;
/* live subtransactions' counts aren't in t_tuples_inserted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_inserted;
@@ -1573,7 +1573,7 @@ pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_updated;
+ result = tabentry->counts.tuples_updated;
/* live subtransactions' counts aren't in t_tuples_updated yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_updated;
@@ -1594,7 +1594,7 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_deleted;
+ result = tabentry->counts.tuples_deleted;
/* live subtransactions' counts aren't in t_tuples_deleted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_deleted;
@@ -1613,7 +1613,7 @@ pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_hot_updated);
+ result = (int64) (tabentry->counts.tuples_hot_updated);
PG_RETURN_INT64(result);
}
@@ -1628,7 +1628,7 @@ pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_fetched);
+ result = (int64) (tabentry->counts.blocks_fetched);
PG_RETURN_INT64(result);
}
@@ -1643,7 +1643,7 @@ pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_hit);
+ result = (int64) (tabentry->counts.blocks_hit);
PG_RETURN_INT64(result);
}
@@ -1656,7 +1656,7 @@ pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_numcalls);
+ PG_RETURN_INT64(funcentry->numcalls);
}
Datum
@@ -1667,7 +1667,7 @@ pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_total_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->total_time));
}
Datum
@@ -1678,7 +1678,7 @@ pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_self_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->self_time));
}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 1e418b682b..9077469657 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -106,9 +106,9 @@ typedef int64 PgStat_Counter;
*/
typedef struct PgStat_FunctionCounts
{
- PgStat_Counter f_numcalls;
- instr_time f_total_time;
- instr_time f_self_time;
+ PgStat_Counter numcalls;
+ instr_time total_time;
+ instr_time self_time;
} PgStat_FunctionCounts;
/*
@@ -124,7 +124,7 @@ typedef struct PgStat_FunctionCallUsage
/* Backend-wide total time as of function start */
instr_time save_total;
/* system clock as of function start */
- instr_time f_start;
+ instr_time start;
} PgStat_FunctionCallUsage;
/* ----------
@@ -159,23 +159,23 @@ typedef struct PgStat_BackendSubEntry
*/
typedef struct PgStat_TableCounts
{
- PgStat_Counter t_numscans;
+ PgStat_Counter numscans;
- PgStat_Counter t_tuples_returned;
- PgStat_Counter t_tuples_fetched;
+ PgStat_Counter tuples_returned;
+ PgStat_Counter tuples_fetched;
- PgStat_Counter t_tuples_inserted;
- PgStat_Counter t_tuples_updated;
- PgStat_Counter t_tuples_deleted;
- PgStat_Counter t_tuples_hot_updated;
- bool t_truncdropped;
+ PgStat_Counter tuples_inserted;
+ PgStat_Counter tuples_updated;
+ PgStat_Counter tuples_deleted;
+ PgStat_Counter tuples_hot_updated;
+ bool truncdropped;
- PgStat_Counter t_delta_live_tuples;
- PgStat_Counter t_delta_dead_tuples;
- PgStat_Counter t_changed_tuples;
+ PgStat_Counter delta_live_tuples;
+ PgStat_Counter delta_dead_tuples;
+ PgStat_Counter changed_tuples;
- PgStat_Counter t_blocks_fetched;
- PgStat_Counter t_blocks_hit;
+ PgStat_Counter blocks_fetched;
+ PgStat_Counter blocks_hit;
} PgStat_TableCounts;
/* ----------
@@ -195,10 +195,10 @@ typedef struct PgStat_TableCounts
*/
typedef struct PgStat_TableStatus
{
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
- PgStat_TableCounts t_counts; /* event counts to be sent */
+ PgStat_TableCounts counts; /* event counts to be sent */
Relation relation; /* rel that is using this entry */
} PgStat_TableStatus;
@@ -351,10 +351,10 @@ typedef struct PgStat_StatDBEntry
typedef struct PgStat_StatFuncEntry
{
- PgStat_Counter f_numcalls;
+ PgStat_Counter numcalls;
- PgStat_Counter f_total_time; /* times in microseconds */
- PgStat_Counter f_self_time;
+ PgStat_Counter total_time; /* times in microseconds */
+ PgStat_Counter self_time;
} PgStat_StatFuncEntry;
typedef struct PgStat_StatReplSlotEntry
@@ -582,37 +582,37 @@ extern void pgstat_report_analyze(Relation rel,
#define pgstat_count_heap_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_heap_getnext(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned++; \
+ (rel)->pgstat_info->counts.tuples_returned++; \
} while (0)
#define pgstat_count_heap_fetch(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_fetched++; \
+ (rel)->pgstat_info->counts.tuples_fetched++; \
} while (0)
#define pgstat_count_index_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_index_tuples(rel, n) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
+ (rel)->pgstat_info->counts.tuples_returned += (n); \
} while (0)
#define pgstat_count_buffer_read(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_fetched++; \
+ (rel)->pgstat_info->counts.blocks_fetched++; \
} while (0)
#define pgstat_count_buffer_hit(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_hit++; \
+ (rel)->pgstat_info->counts.blocks_hit++; \
} while (0)
extern void pgstat_count_heap_insert(Relation rel, PgStat_Counter n);
On Mon, Mar 20, 2023 at 10:05:21AM +0100, Drouvot, Bertrand wrote:
Good point and keeping it as it is currently would not
affect the work that is/will be done in [1].
I guess that I'm OK with that to get more of pgstatfuncs.c to use
macros for the function definitions there.. Alvaro, Tom, perhaps you
still think that this is unadapted? Based on the file split and the
references to funcentry and tabentry, I think that's OK, but that
stands just as one opinion among many..
So, please find attached V2 attached taking this comment into account.
[1]: /messages/by-id/89606d96-cd94-af74-18f3-c7ab2b684ba2@gmail.com
Nice. I am pretty sure that finishing some of that is doable by the
end of this CF to reduce the size of pgstatfuncs.c overall.
--
Michael
On Mon, Mar 20, 2023 at 10:05:21AM +0100, Drouvot, Bertrand wrote:
Hi,
On 3/20/23 8:32 AM, Michael Paquier wrote:
/* Total time previously charged to function, as of function start */ - instr_time save_f_total_time; + instr_time save_total_time; I have something to say about this one, though.. I find this change a bit confusing. It may be better kept as it is, or I think that we'd better rename also "save_total" and "start" to reflect in a better way what they do, because removing "f_" reduces the meaning of the field with the two others in the same structure.Thanks for looking at it!
Good point and keeping it as it is currently would not
affect the work that is/will be done in [1].So, please find attached V2 attached taking this comment into account.
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 35c6d46555..4f21fb2dc2 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -1552,7 +1552,7 @@ pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS) result = 0; else { - result = tabentry->t_counts.t_tuples_inserted; + result = tabentry->counts.tuples_inserted;
This comment still has the t_ prefix as does the one for tuples_updated
and deleted.
otherwise, LGTM.
/* live subtransactions' counts aren't in t_tuples_inserted yet */ for (trans = tabentry->trans; trans != NULL; trans = trans->upper) result += trans->tuples_inserted; @@ -1573,7 +1573,7 @@ pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS) result = 0; else { - result = tabentry->t_counts.t_tuples_updated; + result = tabentry->counts.tuples_updated; /* live subtransactions' counts aren't in t_tuples_updated yet */ for (trans = tabentry->trans; trans != NULL; trans = trans->upper) result += trans->tuples_updated; @@ -1594,7 +1594,7 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS) result = 0; else { - result = tabentry->t_counts.t_tuples_deleted; + result = tabentry->counts.tuples_deleted; /* live subtransactions' counts aren't in t_tuples_deleted yet */ for (trans = tabentry->trans; trans != NULL; trans = trans->upper) result += trans->tuples_deleted; @@ -1613,7 +1613,7 @@ pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS) if ((tabentry = find_tabstat_entry(relid)) == NULL) result = 0; else - result = (int64) (tabentry->t_counts.t_tuples_hot_updated); + result = (int64) (tabentry->counts.tuples_hot_updated);PG_RETURN_INT64(result);
}
- Melanie
On Wed, Mar 22, 2023 at 02:52:23PM -0400, Melanie Plageman wrote:
This comment still has the t_ prefix as does the one for tuples_updated
and deleted.otherwise, LGTM.
Good catch. pgstat_count_heap_update() has a t_tuples_hot_updated,
and pgstat_update_heap_dead_tuples() a t_delta_dead_tuples on top of
the three you have just reported.
I have grepped for all the fields renamed, and nothing else stands
out. However, my eyes don't have a 100% accuracy, either.
--
Michael
Hi,
On 3/23/23 1:09 AM, Michael Paquier wrote:
On Wed, Mar 22, 2023 at 02:52:23PM -0400, Melanie Plageman wrote:
This comment still has the t_ prefix as does the one for tuples_updated
and deleted.otherwise, LGTM.
Good catch. pgstat_count_heap_update() has a t_tuples_hot_updated,
and pgstat_update_heap_dead_tuples() a t_delta_dead_tuples on top of
the three you have just reported.I have grepped for all the fields renamed, and nothing else stands
out. However, my eyes don't have a 100% accuracy, either.
Thank you both for your keen eye! I just did another check too and did not
find more than the ones you've just reported.
Please find attached V3 getting rid of them.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachments:
v3-0001-remove_nonmeaningful_prefixes.patchtext/plain; charset=UTF-8; name=v3-0001-remove_nonmeaningful_prefixes.patchDownload
diff --git a/src/backend/utils/activity/pgstat_function.c b/src/backend/utils/activity/pgstat_function.c
index 0fdcefb783..79e781167b 100644
--- a/src/backend/utils/activity/pgstat_function.c
+++ b/src/backend/utils/activity/pgstat_function.c
@@ -124,13 +124,13 @@ pgstat_init_function_usage(FunctionCallInfo fcinfo,
fcu->fs = pending;
/* save stats for this function, later used to compensate for recursion */
- fcu->save_f_total_time = pending->f_total_time;
+ fcu->save_f_total_time = pending->total_time;
/* save current backend-wide total time */
fcu->save_total = total_func_time;
/* get clock time as of function start */
- INSTR_TIME_SET_CURRENT(fcu->f_start);
+ INSTR_TIME_SET_CURRENT(fcu->start);
}
/*
@@ -146,41 +146,41 @@ void
pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
{
PgStat_FunctionCounts *fs = fcu->fs;
- instr_time f_total;
- instr_time f_others;
- instr_time f_self;
+ instr_time total;
+ instr_time others;
+ instr_time self;
/* stats not wanted? */
if (fs == NULL)
return;
/* total elapsed time in this function call */
- INSTR_TIME_SET_CURRENT(f_total);
- INSTR_TIME_SUBTRACT(f_total, fcu->f_start);
+ INSTR_TIME_SET_CURRENT(total);
+ INSTR_TIME_SUBTRACT(total, fcu->start);
/* self usage: elapsed minus anything already charged to other calls */
- f_others = total_func_time;
- INSTR_TIME_SUBTRACT(f_others, fcu->save_total);
- f_self = f_total;
- INSTR_TIME_SUBTRACT(f_self, f_others);
+ others = total_func_time;
+ INSTR_TIME_SUBTRACT(others, fcu->save_total);
+ self = total;
+ INSTR_TIME_SUBTRACT(self, others);
/* update backend-wide total time */
- INSTR_TIME_ADD(total_func_time, f_self);
+ INSTR_TIME_ADD(total_func_time, self);
/*
- * Compute the new f_total_time as the total elapsed time added to the
- * pre-call value of f_total_time. This is necessary to avoid
+ * Compute the new total_time as the total elapsed time added to the
+ * pre-call value of total_time. This is necessary to avoid
* double-counting any time taken by recursive calls of myself. (We do
* not need any similar kluge for self time, since that already excludes
* any recursive calls.)
*/
- INSTR_TIME_ADD(f_total, fcu->save_f_total_time);
+ INSTR_TIME_ADD(total, fcu->save_f_total_time);
/* update counters in function stats table */
if (finalize)
- fs->f_numcalls++;
- fs->f_total_time = f_total;
- INSTR_TIME_ADD(fs->f_self_time, f_self);
+ fs->numcalls++;
+ fs->total_time = total;
+ INSTR_TIME_ADD(fs->self_time, self);
}
/*
@@ -203,11 +203,11 @@ pgstat_function_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
if (!pgstat_lock_entry(entry_ref, nowait))
return false;
- shfuncent->stats.f_numcalls += localent->f_numcalls;
- shfuncent->stats.f_total_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_total_time);
- shfuncent->stats.f_self_time +=
- INSTR_TIME_GET_MICROSEC(localent->f_self_time);
+ shfuncent->stats.numcalls += localent->numcalls;
+ shfuncent->stats.total_time +=
+ INSTR_TIME_GET_MICROSEC(localent->total_time);
+ shfuncent->stats.self_time +=
+ INSTR_TIME_GET_MICROSEC(localent->self_time);
pgstat_unlock_entry(entry_ref);
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index f793ac1516..8b230778d3 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -38,9 +38,9 @@ typedef struct TwoPhasePgStatRecord
PgStat_Counter inserted_pre_truncdrop;
PgStat_Counter updated_pre_truncdrop;
PgStat_Counter deleted_pre_truncdrop;
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
- bool t_truncdropped; /* was the relation truncated/dropped? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
+ bool truncdropped; /* was the relation truncated/dropped? */
} TwoPhasePgStatRecord;
@@ -310,7 +310,7 @@ pgstat_report_analyze(Relation rel,
deadtuples -= trans->tuples_updated + trans->tuples_deleted;
}
/* count stuff inserted by already-aborted subxacts, too */
- deadtuples -= rel->pgstat_info->t_counts.t_delta_dead_tuples;
+ deadtuples -= rel->pgstat_info->counts.delta_dead_tuples;
/* Since ANALYZE's counts are estimates, we could have underflowed */
livetuples = Max(livetuples, 0);
deadtuples = Max(deadtuples, 0);
@@ -382,9 +382,9 @@ pgstat_count_heap_update(Relation rel, bool hot)
ensure_tabstat_xact_level(pgstat_info);
pgstat_info->trans->tuples_updated++;
- /* t_tuples_hot_updated is nontransactional, so just advance it */
+ /* tuples_hot_updated is nontransactional, so just advance it */
if (hot)
- pgstat_info->t_counts.t_tuples_hot_updated++;
+ pgstat_info->counts.tuples_hot_updated++;
}
}
@@ -425,7 +425,7 @@ pgstat_count_truncate(Relation rel)
* update dead-tuples count
*
* The semantics of this are that we are reporting the nontransactional
- * recovery of "delta" dead tuples; so t_delta_dead_tuples decreases
+ * recovery of "delta" dead tuples; so delta_dead_tuples decreases
* rather than increasing, and the change goes straight into the per-table
* counter, not into transactional state.
*/
@@ -436,7 +436,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta)
{
PgStat_TableStatus *pgstat_info = rel->pgstat_info;
- pgstat_info->t_counts.t_delta_dead_tuples -= delta;
+ pgstat_info->counts.delta_dead_tuples -= delta;
}
}
@@ -512,33 +512,33 @@ AtEOXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit)
if (!isCommit)
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
if (isCommit)
{
- tabstat->t_counts.t_truncdropped = trans->truncdropped;
+ tabstat->counts.truncdropped = trans->truncdropped;
if (trans->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- tabstat->t_counts.t_delta_live_tuples = 0;
- tabstat->t_counts.t_delta_dead_tuples = 0;
+ tabstat->counts.delta_live_tuples = 0;
+ tabstat->counts.delta_dead_tuples = 0;
}
/* insert adds a live tuple, delete removes one */
- tabstat->t_counts.t_delta_live_tuples +=
+ tabstat->counts.delta_live_tuples +=
trans->tuples_inserted - trans->tuples_deleted;
/* update and delete each create a dead tuple */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_updated + trans->tuples_deleted;
/* insert, update, delete each count as one change event */
- tabstat->t_counts.t_changed_tuples +=
+ tabstat->counts.changed_tuples +=
trans->tuples_inserted + trans->tuples_updated +
trans->tuples_deleted;
}
else
{
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
/* an aborted xact generates no changed_tuple events */
}
@@ -618,11 +618,11 @@ AtEOSubXact_PgStat_Relations(PgStat_SubXactStatus *xact_state, bool isCommit, in
/* first restore values obliterated by truncate/drop */
restore_truncdrop_counters(trans);
/* count attempted actions regardless of commit/abort */
- tabstat->t_counts.t_tuples_inserted += trans->tuples_inserted;
- tabstat->t_counts.t_tuples_updated += trans->tuples_updated;
- tabstat->t_counts.t_tuples_deleted += trans->tuples_deleted;
+ tabstat->counts.tuples_inserted += trans->tuples_inserted;
+ tabstat->counts.tuples_updated += trans->tuples_updated;
+ tabstat->counts.tuples_deleted += trans->tuples_deleted;
/* inserted tuples are dead, deleted tuples are unaffected */
- tabstat->t_counts.t_delta_dead_tuples +=
+ tabstat->counts.delta_dead_tuples +=
trans->tuples_inserted + trans->tuples_updated;
tabstat->trans = trans->upper;
pfree(trans);
@@ -655,9 +655,9 @@ AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
record.inserted_pre_truncdrop = trans->inserted_pre_truncdrop;
record.updated_pre_truncdrop = trans->updated_pre_truncdrop;
record.deleted_pre_truncdrop = trans->deleted_pre_truncdrop;
- record.t_id = tabstat->t_id;
- record.t_shared = tabstat->t_shared;
- record.t_truncdropped = trans->truncdropped;
+ record.id = tabstat->id;
+ record.shared = tabstat->shared;
+ record.truncdropped = trans->truncdropped;
RegisterTwoPhaseRecord(TWOPHASE_RM_PGSTAT_ID, 0,
&record, sizeof(TwoPhasePgStatRecord));
@@ -699,24 +699,24 @@ pgstat_twophase_postcommit(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, commit case */
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_truncdropped = rec->t_truncdropped;
- if (rec->t_truncdropped)
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.truncdropped = rec->truncdropped;
+ if (rec->truncdropped)
{
/* forget live/dead stats seen by backend thus far */
- pgstat_info->t_counts.t_delta_live_tuples = 0;
- pgstat_info->t_counts.t_delta_dead_tuples = 0;
+ pgstat_info->counts.delta_live_tuples = 0;
+ pgstat_info->counts.delta_dead_tuples = 0;
}
- pgstat_info->t_counts.t_delta_live_tuples +=
+ pgstat_info->counts.delta_live_tuples +=
rec->tuples_inserted - rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_updated + rec->tuples_deleted;
- pgstat_info->t_counts.t_changed_tuples +=
+ pgstat_info->counts.changed_tuples +=
rec->tuples_inserted + rec->tuples_updated +
rec->tuples_deleted;
}
@@ -735,19 +735,19 @@ pgstat_twophase_postabort(TransactionId xid, uint16 info,
PgStat_TableStatus *pgstat_info;
/* Find or create a tabstat entry for the rel */
- pgstat_info = pgstat_prep_relation_pending(rec->t_id, rec->t_shared);
+ pgstat_info = pgstat_prep_relation_pending(rec->id, rec->shared);
/* Same math as in AtEOXact_PgStat, abort case */
- if (rec->t_truncdropped)
+ if (rec->truncdropped)
{
rec->tuples_inserted = rec->inserted_pre_truncdrop;
rec->tuples_updated = rec->updated_pre_truncdrop;
rec->tuples_deleted = rec->deleted_pre_truncdrop;
}
- pgstat_info->t_counts.t_tuples_inserted += rec->tuples_inserted;
- pgstat_info->t_counts.t_tuples_updated += rec->tuples_updated;
- pgstat_info->t_counts.t_tuples_deleted += rec->tuples_deleted;
- pgstat_info->t_counts.t_delta_dead_tuples +=
+ pgstat_info->counts.tuples_inserted += rec->tuples_inserted;
+ pgstat_info->counts.tuples_updated += rec->tuples_updated;
+ pgstat_info->counts.tuples_deleted += rec->tuples_deleted;
+ pgstat_info->counts.delta_dead_tuples +=
rec->tuples_inserted + rec->tuples_updated;
}
@@ -778,7 +778,7 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
* Ignore entries that didn't accumulate any actual counts, such as
* indexes that were opened by the planner but not used.
*/
- if (memcmp(&lstats->t_counts, &all_zeroes,
+ if (memcmp(&lstats->counts, &all_zeroes,
sizeof(PgStat_TableCounts)) == 0)
{
return true;
@@ -790,37 +790,37 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* add the values to the shared entry. */
tabentry = &shtabstats->stats;
- tabentry->numscans += lstats->t_counts.t_numscans;
- if (lstats->t_counts.t_numscans)
+ tabentry->numscans += lstats->counts.numscans;
+ if (lstats->counts.numscans)
{
TimestampTz t = GetCurrentTransactionStopTimestamp();
if (t > tabentry->lastscan)
tabentry->lastscan = t;
}
- tabentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- tabentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- tabentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- tabentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- tabentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- tabentry->tuples_hot_updated += lstats->t_counts.t_tuples_hot_updated;
+ tabentry->tuples_returned += lstats->counts.tuples_returned;
+ tabentry->tuples_fetched += lstats->counts.tuples_fetched;
+ tabentry->tuples_inserted += lstats->counts.tuples_inserted;
+ tabentry->tuples_updated += lstats->counts.tuples_updated;
+ tabentry->tuples_deleted += lstats->counts.tuples_deleted;
+ tabentry->tuples_hot_updated += lstats->counts.tuples_hot_updated;
/*
* If table was truncated/dropped, first reset the live/dead counters.
*/
- if (lstats->t_counts.t_truncdropped)
+ if (lstats->counts.truncdropped)
{
tabentry->live_tuples = 0;
tabentry->dead_tuples = 0;
tabentry->ins_since_vacuum = 0;
}
- tabentry->live_tuples += lstats->t_counts.t_delta_live_tuples;
- tabentry->dead_tuples += lstats->t_counts.t_delta_dead_tuples;
- tabentry->mod_since_analyze += lstats->t_counts.t_changed_tuples;
- tabentry->ins_since_vacuum += lstats->t_counts.t_tuples_inserted;
- tabentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- tabentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ tabentry->live_tuples += lstats->counts.delta_live_tuples;
+ tabentry->dead_tuples += lstats->counts.delta_dead_tuples;
+ tabentry->mod_since_analyze += lstats->counts.changed_tuples;
+ tabentry->ins_since_vacuum += lstats->counts.tuples_inserted;
+ tabentry->blocks_fetched += lstats->counts.blocks_fetched;
+ tabentry->blocks_hit += lstats->counts.blocks_hit;
/* Clamp live_tuples in case of negative delta_live_tuples */
tabentry->live_tuples = Max(tabentry->live_tuples, 0);
@@ -831,13 +831,13 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
/* The entry was successfully flushed, add the same to database stats */
dbentry = pgstat_prep_database_pending(dboid);
- dbentry->tuples_returned += lstats->t_counts.t_tuples_returned;
- dbentry->tuples_fetched += lstats->t_counts.t_tuples_fetched;
- dbentry->tuples_inserted += lstats->t_counts.t_tuples_inserted;
- dbentry->tuples_updated += lstats->t_counts.t_tuples_updated;
- dbentry->tuples_deleted += lstats->t_counts.t_tuples_deleted;
- dbentry->blocks_fetched += lstats->t_counts.t_blocks_fetched;
- dbentry->blocks_hit += lstats->t_counts.t_blocks_hit;
+ dbentry->tuples_returned += lstats->counts.tuples_returned;
+ dbentry->tuples_fetched += lstats->counts.tuples_fetched;
+ dbentry->tuples_inserted += lstats->counts.tuples_inserted;
+ dbentry->tuples_updated += lstats->counts.tuples_updated;
+ dbentry->tuples_deleted += lstats->counts.tuples_deleted;
+ dbentry->blocks_fetched += lstats->counts.blocks_fetched;
+ dbentry->blocks_hit += lstats->counts.blocks_hit;
return true;
}
@@ -865,8 +865,8 @@ pgstat_prep_relation_pending(Oid rel_id, bool isshared)
isshared ? InvalidOid : MyDatabaseId,
rel_id, NULL);
pending = entry_ref->pending;
- pending->t_id = rel_id;
- pending->t_shared = isshared;
+ pending->id = rel_id;
+ pending->shared = isshared;
return pending;
}
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 35c6d46555..96e7b6fa7a 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -146,7 +146,7 @@ pg_stat_get_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_numcalls);
+ PG_RETURN_INT64(funcentry->numcalls);
}
Datum
@@ -158,7 +158,7 @@ pg_stat_get_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_total_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->total_time) / 1000.0);
}
Datum
@@ -170,7 +170,7 @@ pg_stat_get_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL)
PG_RETURN_NULL();
/* convert counter from microsec to millisec for display */
- PG_RETURN_FLOAT8(((double) funcentry->f_self_time) / 1000.0);
+ PG_RETURN_FLOAT8(((double) funcentry->self_time) / 1000.0);
}
Datum
@@ -1505,7 +1505,7 @@ pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_numscans);
+ result = (int64) (tabentry->counts.numscans);
PG_RETURN_INT64(result);
}
@@ -1520,7 +1520,7 @@ pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_returned);
+ result = (int64) (tabentry->counts.tuples_returned);
PG_RETURN_INT64(result);
}
@@ -1535,7 +1535,7 @@ pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_fetched);
+ result = (int64) (tabentry->counts.tuples_fetched);
PG_RETURN_INT64(result);
}
@@ -1552,8 +1552,8 @@ pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_inserted;
- /* live subtransactions' counts aren't in t_tuples_inserted yet */
+ result = tabentry->counts.tuples_inserted;
+ /* live subtransactions' counts aren't in tuples_inserted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_inserted;
}
@@ -1573,8 +1573,8 @@ pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_updated;
- /* live subtransactions' counts aren't in t_tuples_updated yet */
+ result = tabentry->counts.tuples_updated;
+ /* live subtransactions' counts aren't in tuples_updated yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_updated;
}
@@ -1594,8 +1594,8 @@ pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
result = 0;
else
{
- result = tabentry->t_counts.t_tuples_deleted;
- /* live subtransactions' counts aren't in t_tuples_deleted yet */
+ result = tabentry->counts.tuples_deleted;
+ /* live subtransactions' counts aren't in tuples_deleted yet */
for (trans = tabentry->trans; trans != NULL; trans = trans->upper)
result += trans->tuples_deleted;
}
@@ -1613,7 +1613,7 @@ pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_tuples_hot_updated);
+ result = (int64) (tabentry->counts.tuples_hot_updated);
PG_RETURN_INT64(result);
}
@@ -1628,7 +1628,7 @@ pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_fetched);
+ result = (int64) (tabentry->counts.blocks_fetched);
PG_RETURN_INT64(result);
}
@@ -1643,7 +1643,7 @@ pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
if ((tabentry = find_tabstat_entry(relid)) == NULL)
result = 0;
else
- result = (int64) (tabentry->t_counts.t_blocks_hit);
+ result = (int64) (tabentry->counts.blocks_hit);
PG_RETURN_INT64(result);
}
@@ -1656,7 +1656,7 @@ pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_INT64(funcentry->f_numcalls);
+ PG_RETURN_INT64(funcentry->numcalls);
}
Datum
@@ -1667,7 +1667,7 @@ pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_total_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->total_time));
}
Datum
@@ -1678,7 +1678,7 @@ pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
if ((funcentry = find_funcstat_entry(funcid)) == NULL)
PG_RETURN_NULL();
- PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->f_self_time));
+ PG_RETURN_FLOAT8(INSTR_TIME_GET_MILLISEC(funcentry->self_time));
}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 1e418b682b..9077469657 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -106,9 +106,9 @@ typedef int64 PgStat_Counter;
*/
typedef struct PgStat_FunctionCounts
{
- PgStat_Counter f_numcalls;
- instr_time f_total_time;
- instr_time f_self_time;
+ PgStat_Counter numcalls;
+ instr_time total_time;
+ instr_time self_time;
} PgStat_FunctionCounts;
/*
@@ -124,7 +124,7 @@ typedef struct PgStat_FunctionCallUsage
/* Backend-wide total time as of function start */
instr_time save_total;
/* system clock as of function start */
- instr_time f_start;
+ instr_time start;
} PgStat_FunctionCallUsage;
/* ----------
@@ -159,23 +159,23 @@ typedef struct PgStat_BackendSubEntry
*/
typedef struct PgStat_TableCounts
{
- PgStat_Counter t_numscans;
+ PgStat_Counter numscans;
- PgStat_Counter t_tuples_returned;
- PgStat_Counter t_tuples_fetched;
+ PgStat_Counter tuples_returned;
+ PgStat_Counter tuples_fetched;
- PgStat_Counter t_tuples_inserted;
- PgStat_Counter t_tuples_updated;
- PgStat_Counter t_tuples_deleted;
- PgStat_Counter t_tuples_hot_updated;
- bool t_truncdropped;
+ PgStat_Counter tuples_inserted;
+ PgStat_Counter tuples_updated;
+ PgStat_Counter tuples_deleted;
+ PgStat_Counter tuples_hot_updated;
+ bool truncdropped;
- PgStat_Counter t_delta_live_tuples;
- PgStat_Counter t_delta_dead_tuples;
- PgStat_Counter t_changed_tuples;
+ PgStat_Counter delta_live_tuples;
+ PgStat_Counter delta_dead_tuples;
+ PgStat_Counter changed_tuples;
- PgStat_Counter t_blocks_fetched;
- PgStat_Counter t_blocks_hit;
+ PgStat_Counter blocks_fetched;
+ PgStat_Counter blocks_hit;
} PgStat_TableCounts;
/* ----------
@@ -195,10 +195,10 @@ typedef struct PgStat_TableCounts
*/
typedef struct PgStat_TableStatus
{
- Oid t_id; /* table's OID */
- bool t_shared; /* is it a shared catalog? */
+ Oid id; /* table's OID */
+ bool shared; /* is it a shared catalog? */
struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */
- PgStat_TableCounts t_counts; /* event counts to be sent */
+ PgStat_TableCounts counts; /* event counts to be sent */
Relation relation; /* rel that is using this entry */
} PgStat_TableStatus;
@@ -351,10 +351,10 @@ typedef struct PgStat_StatDBEntry
typedef struct PgStat_StatFuncEntry
{
- PgStat_Counter f_numcalls;
+ PgStat_Counter numcalls;
- PgStat_Counter f_total_time; /* times in microseconds */
- PgStat_Counter f_self_time;
+ PgStat_Counter total_time; /* times in microseconds */
+ PgStat_Counter self_time;
} PgStat_StatFuncEntry;
typedef struct PgStat_StatReplSlotEntry
@@ -582,37 +582,37 @@ extern void pgstat_report_analyze(Relation rel,
#define pgstat_count_heap_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_heap_getnext(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned++; \
+ (rel)->pgstat_info->counts.tuples_returned++; \
} while (0)
#define pgstat_count_heap_fetch(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_fetched++; \
+ (rel)->pgstat_info->counts.tuples_fetched++; \
} while (0)
#define pgstat_count_index_scan(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_numscans++; \
+ (rel)->pgstat_info->counts.numscans++; \
} while (0)
#define pgstat_count_index_tuples(rel, n) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \
+ (rel)->pgstat_info->counts.tuples_returned += (n); \
} while (0)
#define pgstat_count_buffer_read(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_fetched++; \
+ (rel)->pgstat_info->counts.blocks_fetched++; \
} while (0)
#define pgstat_count_buffer_hit(rel) \
do { \
if (pgstat_should_count_relation(rel)) \
- (rel)->pgstat_info->t_counts.t_blocks_hit++; \
+ (rel)->pgstat_info->counts.blocks_hit++; \
} while (0)
extern void pgstat_count_heap_insert(Relation rel, PgStat_Counter n);
On Thu, Mar 23, 2023 at 07:51:37AM +0100, Drouvot, Bertrand wrote:
Thank you both for your keen eye! I just did another check too and did not
find more than the ones you've just reported.
This matches what I have, thanks!
--
Michael
On Thu, Mar 23, 2023 at 05:24:22PM +0900, Michael Paquier wrote:
On Thu, Mar 23, 2023 at 07:51:37AM +0100, Drouvot, Bertrand wrote:
Thank you both for your keen eye! I just did another check too and did not
find more than the ones you've just reported.This matches what I have, thanks!
Applied that, after handling the new t_tuples_newpage_updated.
--
Michael