PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/twophase_rmgr.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
#include "utils/rel.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | TwoPhasePgStatRecord |
Typedefs | |
typedef struct TwoPhasePgStatRecord | TwoPhasePgStatRecord |
typedef struct TwoPhasePgStatRecord TwoPhasePgStatRecord |
|
static |
Definition at line 913 of file pgstat_relation.c.
References PgStat_SubXactStatus::first, MemoryContextAllocZero(), pgstat_get_xact_stack_level(), TopTransactionContext, PgStat_TableStatus::trans, and trans.
Referenced by ensure_tabstat_xact_level().
void AtEOSubXact_PgStat_Relations | ( | PgStat_SubXactStatus * | xact_state, |
bool | isCommit, | ||
int | nestDepth | ||
) |
Definition at line 594 of file pgstat_relation.c.
References Assert, PgStat_TableStatus::counts, PgStat_TableCounts::delta_dead_tuples, PgStat_SubXactStatus::first, pfree(), pgstat_get_xact_stack_level(), restore_truncdrop_counters(), save_truncdrop_counters(), PgStat_TableStatus::trans, trans, PgStat_TableCounts::tuples_deleted, PgStat_TableCounts::tuples_inserted, and PgStat_TableCounts::tuples_updated.
Referenced by AtEOSubXact_PgStat().
void AtEOXact_PgStat_Relations | ( | PgStat_SubXactStatus * | xact_state, |
bool | isCommit | ||
) |
Definition at line 536 of file pgstat_relation.c.
References Assert, PgStat_TableCounts::changed_tuples, PgStat_TableStatus::counts, PgStat_TableCounts::delta_dead_tuples, PgStat_TableCounts::delta_live_tuples, PgStat_SubXactStatus::first, restore_truncdrop_counters(), PgStat_TableStatus::trans, trans, PgStat_TableCounts::truncdropped, PgStat_TableCounts::tuples_deleted, PgStat_TableCounts::tuples_inserted, and PgStat_TableCounts::tuples_updated.
Referenced by AtEOXact_PgStat().
void AtPrepare_PgStat_Relations | ( | PgStat_SubXactStatus * | xact_state | ) |
Definition at line 675 of file pgstat_relation.c.
References Assert, TwoPhasePgStatRecord::deleted_pre_truncdrop, PgStat_SubXactStatus::first, TwoPhasePgStatRecord::id, TwoPhasePgStatRecord::inserted_pre_truncdrop, PG_USED_FOR_ASSERTS_ONLY, RegisterTwoPhaseRecord(), TwoPhasePgStatRecord::shared, trans, TwoPhasePgStatRecord::truncdropped, TwoPhasePgStatRecord::tuples_deleted, TwoPhasePgStatRecord::tuples_inserted, TwoPhasePgStatRecord::tuples_updated, TWOPHASE_RM_PGSTAT_ID, and TwoPhasePgStatRecord::updated_pre_truncdrop.
Referenced by AtPrepare_PgStat().
|
static |
Definition at line 940 of file pgstat_relation.c.
References add_tabstat_xact_level(), GetCurrentTransactionNestLevel(), PgStat_TableXactStatus::nest_level, and PgStat_TableStatus::trans.
Referenced by pgstat_count_heap_delete(), pgstat_count_heap_insert(), pgstat_count_heap_update(), and pgstat_count_truncate().
PgStat_TableStatus* find_tabstat_entry | ( | Oid | rel_id | ) |
Definition at line 486 of file pgstat_relation.c.
References PgStat_TableStatus::counts, InvalidOid, MyDatabaseId, palloc(), PgStat_EntryRef::pending, pgstat_fetch_pending_entry(), PGSTAT_KIND_RELATION, PgStat_TableStatus::trans, trans, PgStat_TableCounts::tuples_deleted, PgStat_TableCounts::tuples_inserted, and PgStat_TableCounts::tuples_updated.
void pgstat_assoc_relation | ( | Relation | rel | ) |
Definition at line 131 of file pgstat_relation.c.
References Assert, RelationData::pgstat_enabled, RelationData::pgstat_info, pgstat_prep_relation_pending(), RelationData::rd_rel, PgStat_TableStatus::relation, and RelationGetRelid.
Definition at line 57 of file pgstat_relation.c.
References InvalidOid, MyDatabaseId, pgstat_fetch_stat_tabentry_ext(), pgstat_get_entry_ref_locked(), PGSTAT_KIND_RELATION, pgstat_unlock_entry(), RelationData::rd_rel, RelationGetRelid, PgStat_EntryRef::shared_stats, and PgStatShared_Relation::stats.
Referenced by index_concurrently_swap().
void pgstat_count_heap_delete | ( | Relation | rel | ) |
Definition at line 400 of file pgstat_relation.c.
References ensure_tabstat_xact_level(), RelationData::pgstat_info, pgstat_should_count_relation, PgStat_TableStatus::trans, and PgStat_TableXactStatus::tuples_deleted.
Referenced by heap_abort_speculative(), and heap_delete().
void pgstat_count_heap_insert | ( | Relation | rel, |
PgStat_Counter | n | ||
) |
Definition at line 359 of file pgstat_relation.c.
References ensure_tabstat_xact_level(), RelationData::pgstat_info, pgstat_should_count_relation, PgStat_TableStatus::trans, and PgStat_TableXactStatus::tuples_inserted.
Referenced by heap_insert(), heap_multi_insert(), and RefreshMatViewByOid().
void pgstat_count_heap_update | ( | Relation | rel, |
bool | hot, | ||
bool | newpage | ||
) |
Definition at line 374 of file pgstat_relation.c.
References Assert, PgStat_TableStatus::counts, ensure_tabstat_xact_level(), RelationData::pgstat_info, pgstat_should_count_relation, PgStat_TableStatus::trans, PgStat_TableCounts::tuples_hot_updated, PgStat_TableCounts::tuples_newpage_updated, and PgStat_TableXactStatus::tuples_updated.
Referenced by heap_update().
void pgstat_count_truncate | ( | Relation | rel | ) |
Definition at line 415 of file pgstat_relation.c.
References ensure_tabstat_xact_level(), RelationData::pgstat_info, pgstat_should_count_relation, save_truncdrop_counters(), PgStat_TableStatus::trans, PgStat_TableXactStatus::tuples_deleted, PgStat_TableXactStatus::tuples_inserted, and PgStat_TableXactStatus::tuples_updated.
Referenced by ExecuteTruncateGuts(), and RefreshMatViewByOid().
void pgstat_create_relation | ( | Relation | rel | ) |
Definition at line 168 of file pgstat_relation.c.
References InvalidOid, MyDatabaseId, pgstat_create_transactional(), PGSTAT_KIND_RELATION, RelationData::rd_rel, and RelationGetRelid.
Referenced by heap_create().
void pgstat_drop_relation | ( | Relation | rel | ) |
Definition at line 179 of file pgstat_relation.c.
References GetCurrentTransactionNestLevel(), InvalidOid, MyDatabaseId, PgStat_TableXactStatus::nest_level, pgstat_drop_transactional(), RelationData::pgstat_info, PGSTAT_KIND_RELATION, pgstat_should_count_relation, RelationData::rd_rel, RelationGetRelid, save_truncdrop_counters(), PgStat_TableStatus::trans, PgStat_TableXactStatus::tuples_deleted, PgStat_TableXactStatus::tuples_inserted, and PgStat_TableXactStatus::tuples_updated.
Referenced by heap_drop_with_catalog(), and index_drop().
PgStat_StatTabEntry* pgstat_fetch_stat_tabentry | ( | Oid | relid | ) |
Definition at line 455 of file pgstat_relation.c.
References IsSharedRelation(), and pgstat_fetch_stat_tabentry_ext().
PgStat_StatTabEntry* pgstat_fetch_stat_tabentry_ext | ( | bool | shared, |
Oid | reloid | ||
) |
Definition at line 465 of file pgstat_relation.c.
References InvalidOid, MyDatabaseId, pgstat_fetch_entry(), and PGSTAT_KIND_RELATION.
Referenced by do_autovacuum(), pgstat_copy_relation_stats(), pgstat_fetch_stat_tabentry(), and recheck_relation_needs_vacanalyze().
void pgstat_init_relation | ( | Relation | rel | ) |
Definition at line 91 of file pgstat_relation.c.
References RelationData::pgstat_enabled, RelationData::pgstat_info, pgstat_track_counts, pgstat_unlink_relation(), and RelationData::rd_rel.
Referenced by relation_open(), and try_relation_open().
|
static |
Definition at line 894 of file pgstat_relation.c.
References PgStat_TableStatus::id, InvalidOid, MyDatabaseId, PgStat_EntryRef::pending, PGSTAT_KIND_RELATION, pgstat_prep_pending_entry(), and PgStat_TableStatus::shared.
Referenced by pgstat_assoc_relation(), pgstat_twophase_postabort(), and pgstat_twophase_postcommit().
void pgstat_relation_delete_pending_cb | ( | PgStat_EntryRef * | entry_ref | ) |
Definition at line 881 of file pgstat_relation.c.
References if(), PgStat_EntryRef::pending, pgstat_unlink_relation(), and PgStat_TableStatus::relation.
bool pgstat_relation_flush_cb | ( | PgStat_EntryRef * | entry_ref, |
bool | nowait | ||
) |
Definition at line 801 of file pgstat_relation.c.
References PgStat_TableCounts::blocks_fetched, PgStat_StatDBEntry::blocks_fetched, PgStat_StatTabEntry::blocks_fetched, PgStat_TableCounts::blocks_hit, PgStat_StatDBEntry::blocks_hit, PgStat_StatTabEntry::blocks_hit, PgStat_TableCounts::changed_tuples, PgStat_TableStatus::counts, PgStat_HashKey::dboid, PgStat_StatTabEntry::dead_tuples, PgStat_TableCounts::delta_dead_tuples, PgStat_TableCounts::delta_live_tuples, GetCurrentTransactionStopTimestamp(), PgStat_StatTabEntry::ins_since_vacuum, PgStatShared_HashEntry::key, PgStat_StatTabEntry::lastscan, PgStat_StatTabEntry::live_tuples, Max, PgStat_StatTabEntry::mod_since_analyze, PgStat_TableCounts::numscans, PgStat_StatTabEntry::numscans, PgStat_EntryRef::pending, pg_memory_is_all_zeros(), pgstat_lock_entry(), pgstat_prep_database_pending(), pgstat_unlock_entry(), PgStat_EntryRef::shared_entry, PgStat_EntryRef::shared_stats, PgStatShared_Relation::stats, PgStat_TableCounts::truncdropped, PgStat_TableCounts::tuples_deleted, PgStat_StatDBEntry::tuples_deleted, PgStat_StatTabEntry::tuples_deleted, PgStat_TableCounts::tuples_fetched, PgStat_StatDBEntry::tuples_fetched, PgStat_StatTabEntry::tuples_fetched, PgStat_TableCounts::tuples_hot_updated, PgStat_StatTabEntry::tuples_hot_updated, PgStat_TableCounts::tuples_inserted, PgStat_StatDBEntry::tuples_inserted, PgStat_StatTabEntry::tuples_inserted, PgStat_TableCounts::tuples_newpage_updated, PgStat_StatTabEntry::tuples_newpage_updated, PgStat_TableCounts::tuples_returned, PgStat_StatDBEntry::tuples_returned, PgStat_StatTabEntry::tuples_returned, PgStat_TableCounts::tuples_updated, PgStat_StatDBEntry::tuples_updated, and PgStat_StatTabEntry::tuples_updated.
void pgstat_report_analyze | ( | Relation | rel, |
PgStat_Counter | livetuples, | ||
PgStat_Counter | deadtuples, | ||
bool | resetcounter | ||
) |
Definition at line 276 of file pgstat_relation.c.
References AmAutoVacuumWorkerProcess, PgStat_StatTabEntry::analyze_count, Assert, PgStat_StatTabEntry::autoanalyze_count, PgStat_TableStatus::counts, PgStat_StatTabEntry::dead_tuples, PgStat_TableCounts::delta_dead_tuples, GetCurrentTimestamp(), if(), InvalidOid, PgStat_StatTabEntry::last_analyze_time, PgStat_StatTabEntry::last_autoanalyze_time, PgStat_StatTabEntry::live_tuples, Max, PgStat_StatTabEntry::mod_since_analyze, MyDatabaseId, pgstat_flush_io(), pgstat_get_entry_ref_locked(), RelationData::pgstat_info, PGSTAT_KIND_RELATION, pgstat_should_count_relation, pgstat_track_counts, pgstat_unlock_entry(), RelationData::rd_rel, RelationGetRelid, PgStat_EntryRef::shared_stats, PgStatShared_Relation::stats, PgStat_TableStatus::trans, and trans.
Referenced by do_analyze_rel().
void pgstat_report_vacuum | ( | Oid | tableoid, |
bool | shared, | ||
PgStat_Counter | livetuples, | ||
PgStat_Counter | deadtuples | ||
) |
Definition at line 210 of file pgstat_relation.c.
References AmAutoVacuumWorkerProcess, PgStat_StatTabEntry::autovacuum_count, PgStat_StatTabEntry::dead_tuples, GetCurrentTimestamp(), if(), PgStat_StatTabEntry::ins_since_vacuum, InvalidOid, PgStat_StatTabEntry::last_autovacuum_time, PgStat_StatTabEntry::last_vacuum_time, PgStat_StatTabEntry::live_tuples, MyDatabaseId, pgstat_flush_io(), pgstat_get_entry_ref_locked(), PGSTAT_KIND_RELATION, pgstat_track_counts, pgstat_unlock_entry(), PgStat_EntryRef::shared_stats, PgStatShared_Relation::stats, and PgStat_StatTabEntry::vacuum_count.
Referenced by heap_vacuum_rel().
void pgstat_twophase_postabort | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 768 of file pgstat_relation.c.
References PgStat_TableStatus::counts, TwoPhasePgStatRecord::deleted_pre_truncdrop, PgStat_TableCounts::delta_dead_tuples, TwoPhasePgStatRecord::id, TwoPhasePgStatRecord::inserted_pre_truncdrop, pgstat_prep_relation_pending(), TwoPhasePgStatRecord::shared, TwoPhasePgStatRecord::truncdropped, TwoPhasePgStatRecord::tuples_deleted, PgStat_TableCounts::tuples_deleted, TwoPhasePgStatRecord::tuples_inserted, PgStat_TableCounts::tuples_inserted, TwoPhasePgStatRecord::tuples_updated, PgStat_TableCounts::tuples_updated, and TwoPhasePgStatRecord::updated_pre_truncdrop.
void pgstat_twophase_postcommit | ( | TransactionId | xid, |
uint16 | info, | ||
void * | recdata, | ||
uint32 | len | ||
) |
Definition at line 732 of file pgstat_relation.c.
References PgStat_TableCounts::changed_tuples, PgStat_TableStatus::counts, PgStat_TableCounts::delta_dead_tuples, PgStat_TableCounts::delta_live_tuples, TwoPhasePgStatRecord::id, pgstat_prep_relation_pending(), TwoPhasePgStatRecord::shared, TwoPhasePgStatRecord::truncdropped, PgStat_TableCounts::truncdropped, TwoPhasePgStatRecord::tuples_deleted, PgStat_TableCounts::tuples_deleted, TwoPhasePgStatRecord::tuples_inserted, PgStat_TableCounts::tuples_inserted, TwoPhasePgStatRecord::tuples_updated, and PgStat_TableCounts::tuples_updated.
void pgstat_unlink_relation | ( | Relation | rel | ) |
Definition at line 152 of file pgstat_relation.c.
References Assert, RelationData::pgstat_info, and PgStat_TableStatus::relation.
Referenced by pgstat_init_relation(), pgstat_relation_delete_pending_cb(), and RelationDestroyRelation().
void pgstat_update_heap_dead_tuples | ( | Relation | rel, |
int | delta | ||
) |
Definition at line 438 of file pgstat_relation.c.
References PgStat_TableStatus::counts, PgStat_TableCounts::delta_dead_tuples, RelationData::pgstat_info, and pgstat_should_count_relation.
Referenced by heap_page_prune_opt().
void PostPrepare_PgStat_Relations | ( | PgStat_SubXactStatus * | xact_state | ) |
Definition at line 713 of file pgstat_relation.c.
References PgStat_SubXactStatus::first, PgStat_TableStatus::trans, and trans.
Referenced by PostPrepare_PgStat().
|
static |
Definition at line 974 of file pgstat_relation.c.
References trans.
Referenced by AtEOSubXact_PgStat_Relations(), and AtEOXact_PgStat_Relations().
|
static |
Definition at line 959 of file pgstat_relation.c.
References trans.
Referenced by AtEOSubXact_PgStat_Relations(), pgstat_count_truncate(), and pgstat_drop_relation().