PostgreSQL Source Code
git master
|
#include "access/htup.h"
#include "catalog/pg_class.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "parser/parse_node.h"
#include "storage/buf.h"
#include "storage/lock.h"
#include "utils/relcache.h"
Go to the source code of this file.
Data Structures | |
struct | VacAttrStats |
struct | VacuumParams |
Macros | |
#define | VACUUM_OPTION_NO_PARALLEL 0 |
#define | VACUUM_OPTION_PARALLEL_BULKDEL (1 << 0) |
#define | VACUUM_OPTION_PARALLEL_COND_CLEANUP (1 << 1) |
#define | VACUUM_OPTION_PARALLEL_CLEANUP (1 << 2) |
#define | VACUUM_OPTION_MAX_VALID_VALUE ((1 << 3) - 1) |
#define | VACOPT_VACUUM 0x01 /* do VACUUM */ |
#define | VACOPT_ANALYZE 0x02 /* do ANALYZE */ |
#define | VACOPT_VERBOSE 0x04 /* print progress info */ |
#define | VACOPT_FREEZE 0x08 /* FREEZE option */ |
#define | VACOPT_FULL 0x10 /* FULL (non-concurrent) vacuum */ |
#define | VACOPT_SKIP_LOCKED 0x20 /* skip if cannot get lock */ |
#define | VACOPT_SKIPTOAST 0x40 /* don't process the TOAST table, if any */ |
#define | VACOPT_DISABLE_PAGE_SKIPPING 0x80 /* don't skip any pages */ |
Typedefs | |
typedef struct VacAttrStats * | VacAttrStatsP |
typedef Datum(* | AnalyzeAttrFetchFunc) (VacAttrStatsP stats, int rownum, bool *isNull) |
typedef void(* | AnalyzeAttrComputeStatsFunc) (VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows) |
typedef struct VacAttrStats | VacAttrStats |
typedef enum VacOptTernaryValue | VacOptTernaryValue |
typedef struct VacuumParams | VacuumParams |
Enumerations | |
enum | VacOptTernaryValue { VACOPT_TERNARY_DEFAULT = 0, VACOPT_TERNARY_DISABLED, VACOPT_TERNARY_ENABLED } |
Functions | |
void | ExecVacuum (ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) |
void | vacuum (List *relations, VacuumParams *params, BufferAccessStrategy bstrategy, bool isTopLevel) |
void | vac_open_indexes (Relation relation, LOCKMODE lockmode, int *nindexes, Relation **Irel) |
void | vac_close_indexes (int nindexes, Relation *Irel, LOCKMODE lockmode) |
double | vac_estimate_reltuples (Relation relation, BlockNumber total_pages, BlockNumber scanned_pages, double scanned_tuples) |
void | vac_update_relstats (Relation relation, BlockNumber num_pages, double num_tuples, BlockNumber num_all_visible_pages, bool hasindex, TransactionId frozenxid, MultiXactId minmulti, bool in_outer_xact) |
void | vacuum_set_xid_limits (Relation rel, int freeze_min_age, int freeze_table_age, int multixact_freeze_min_age, int multixact_freeze_table_age, TransactionId *oldestXmin, TransactionId *freezeLimit, TransactionId *xidFullScanLimit, MultiXactId *multiXactCutoff, MultiXactId *mxactFullScanLimit) |
void | vac_update_datfrozenxid (void) |
void | vacuum_delay_point (void) |
bool | vacuum_is_relation_owner (Oid relid, Form_pg_class reltuple, bits32 options) |
Relation | vacuum_open_relation (Oid relid, RangeVar *relation, bits32 options, bool verbose, LOCKMODE lmode) |
void | analyze_rel (Oid relid, RangeVar *relation, VacuumParams *params, List *va_cols, bool in_outer_xact, BufferAccessStrategy bstrategy) |
bool | std_typanalyze (VacAttrStats *stats) |
double | anl_random_fract (void) |
double | anl_init_selection_state (int n) |
double | anl_get_next_S (double t, int n, double *stateptr) |
#define VACOPT_ANALYZE 0x02 /* do ANALYZE */ |
Definition at line 179 of file vacuum.h.
Referenced by analyze_rel(), autovac_report_activity(), ExecVacuum(), table_recheck_autovac(), vacuum(), vacuum_is_relation_owner(), and vacuum_open_relation().
#define VACOPT_DISABLE_PAGE_SKIPPING 0x80 /* don't skip any pages */ |
Definition at line 185 of file vacuum.h.
Referenced by ExecVacuum(), heap_vacuum_rel(), lazy_scan_heap(), and vacuum().
#define VACOPT_FREEZE 0x08 /* FREEZE option */ |
Definition at line 181 of file vacuum.h.
Referenced by ExecVacuum().
#define VACOPT_FULL 0x10 /* FULL (non-concurrent) vacuum */ |
Definition at line 182 of file vacuum.h.
Referenced by ExecVacuum(), vacuum(), and vacuum_rel().
#define VACOPT_SKIP_LOCKED 0x20 /* skip if cannot get lock */ |
Definition at line 183 of file vacuum.h.
Referenced by ExecVacuum(), expand_vacuum_rel(), table_recheck_autovac(), and vacuum_open_relation().
#define VACOPT_SKIPTOAST 0x40 /* don't process the TOAST table, if any */ |
Definition at line 184 of file vacuum.h.
Referenced by ExecVacuum(), table_recheck_autovac(), and vacuum_rel().
#define VACOPT_VACUUM 0x01 /* do VACUUM */ |
Definition at line 178 of file vacuum.h.
Referenced by analyze_rel(), autovac_report_activity(), do_analyze_rel(), do_autovacuum(), ExecVacuum(), expand_vacuum_rel(), table_recheck_autovac(), vacuum(), vacuum_is_relation_owner(), vacuum_open_relation(), and vacuum_rel().
#define VACOPT_VERBOSE 0x04 /* print progress info */ |
Definition at line 180 of file vacuum.h.
Referenced by analyze_rel(), ExecVacuum(), heap_vacuum_rel(), and vacuum_rel().
#define VACUUM_OPTION_MAX_VALID_VALUE ((1 << 3) - 1) |
Definition at line 63 of file vacuum.h.
Referenced by begin_parallel_vacuum().
#define VACUUM_OPTION_NO_PARALLEL 0 |
Definition at line 39 of file vacuum.h.
Referenced by compute_parallel_vacuum_workers(), and dihandler().
#define VACUUM_OPTION_PARALLEL_BULKDEL (1 << 0) |
Definition at line 45 of file vacuum.h.
Referenced by begin_parallel_vacuum(), blhandler(), bthandler(), compute_parallel_vacuum_workers(), ginhandler(), gisthandler(), hashhandler(), skip_parallel_vacuum_index(), and spghandler().
#define VACUUM_OPTION_PARALLEL_CLEANUP (1 << 2) |
Definition at line 60 of file vacuum.h.
Referenced by begin_parallel_vacuum(), blhandler(), brinhandler(), compute_parallel_vacuum_workers(), ginhandler(), and skip_parallel_vacuum_index().
#define VACUUM_OPTION_PARALLEL_COND_CLEANUP (1 << 1) |
Definition at line 52 of file vacuum.h.
Referenced by begin_parallel_vacuum(), bthandler(), compute_parallel_vacuum_workers(), gisthandler(), skip_parallel_vacuum_index(), and spghandler().
typedef void(* AnalyzeAttrComputeStatsFunc) (VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows) |
typedef Datum(* AnalyzeAttrFetchFunc) (VacAttrStatsP stats, int rownum, bool *isNull) |
typedef struct VacAttrStats VacAttrStats |
typedef struct VacAttrStats* VacAttrStatsP |
typedef enum VacOptTernaryValue VacOptTernaryValue |
typedef struct VacuumParams VacuumParams |
enum VacOptTernaryValue |
Enumerator | |
---|---|
VACOPT_TERNARY_DEFAULT | |
VACOPT_TERNARY_DISABLED | |
VACOPT_TERNARY_ENABLED |
void analyze_rel | ( | Oid | relid, |
RangeVar * | relation, | ||
VacuumParams * | params, | ||
List * | va_cols, | ||
bool | in_outer_xact, | ||
BufferAccessStrategy | bstrategy | ||
) |
Definition at line 119 of file analyze.c.
References acquire_sample_rows(), FdwRoutine::AnalyzeForeignTable, CHECK_FOR_INTERRUPTS, DEBUG2, do_analyze_rel(), elevel, ereport, errmsg(), GetFdwRoutineForRelation(), INFO, VacuumParams::log_min_duration, NoLock, VacuumParams::options, pgstat_progress_end_command(), pgstat_progress_start_command(), PROGRESS_COMMAND_ANALYZE, RelationData::rd_rel, relation_close(), RELATION_IS_OTHER_TEMP, RelationGetNumberOfBlocks, RelationGetRelationName, RelationGetRelid, ShareUpdateExclusiveLock, VACOPT_ANALYZE, VACOPT_VACUUM, VACOPT_VERBOSE, vacuum_is_relation_owner(), vacuum_open_relation(), and WARNING.
Referenced by vacuum().
double anl_get_next_S | ( | double | t, |
int | n, | ||
double * | stateptr | ||
) |
Definition at line 288 of file sampling.c.
double anl_init_selection_state | ( | int | n | ) |
Definition at line 277 of file sampling.c.
double anl_random_fract | ( | void | ) |
Definition at line 266 of file sampling.c.
void ExecVacuum | ( | ParseState * | pstate, |
VacuumStmt * | vacstmt, | ||
bool | isTopLevel | ||
) |
Definition at line 98 of file vacuum.c.
References analyze(), DefElem::arg, Assert, defGetBoolean(), defGetInt32(), DefElem::defname, ereport, errcode(), errmsg(), ERROR, VacuumParams::freeze_min_age, VacuumParams::freeze_table_age, get_vacopt_ternary_value(), VacuumParams::index_cleanup, VacuumStmt::is_vacuumcmd, VacuumParams::is_wraparound, lfirst, lfirst_node, DefElem::location, VacuumParams::log_min_duration, MAX_PARALLEL_WORKER_LIMIT, VacuumParams::multixact_freeze_min_age, VacuumParams::multixact_freeze_table_age, NIL, VacuumParams::nworkers, VacuumParams::options, VacuumStmt::options, parser_errposition(), VacuumStmt::rels, VacuumParams::truncate, VacuumRelation::va_cols, VACOPT_ANALYZE, VACOPT_DISABLE_PAGE_SKIPPING, VACOPT_FREEZE, VACOPT_FULL, VACOPT_SKIP_LOCKED, VACOPT_SKIPTOAST, VACOPT_TERNARY_DEFAULT, VACOPT_VACUUM, VACOPT_VERBOSE, vacuum(), and verbose.
Referenced by standard_ProcessUtility().
bool std_typanalyze | ( | VacAttrStats * | stats | ) |
Definition at line 1680 of file analyze.c.
References VacAttrStats::attr, VacAttrStats::attrtypid, compute_distinct_stats(), compute_scalar_stats(), VacAttrStats::compute_stats, compute_trivial_stats(), default_statistics_target, StdAnalyzeData::eqfunc, StdAnalyzeData::eqopr, VacAttrStats::extra_data, get_opcode(), get_sort_group_operators(), InvalidOid, StdAnalyzeData::ltopr, VacAttrStats::minrows, OidIsValid, and palloc().
Referenced by array_typanalyze(), and examine_attribute().
Definition at line 2026 of file vacuum.c.
References index_close(), and pfree().
Referenced by do_analyze_rel(), heap_vacuum_rel(), and parallel_vacuum_main().
double vac_estimate_reltuples | ( | Relation | relation, |
BlockNumber | total_pages, | ||
BlockNumber | scanned_pages, | ||
double | scanned_tuples | ||
) |
Definition at line 1141 of file vacuum.c.
References RelationData::rd_rel.
Referenced by lazy_scan_heap(), and statapprox_heap().
Definition at line 1983 of file vacuum.c.
References Assert, i, index_close(), index_open(), lfirst_oid, list_free(), list_length(), NoLock, palloc(), RelationData::rd_index, and RelationGetIndexList().
Referenced by do_analyze_rel(), heap_vacuum_rel(), and parallel_vacuum_main().
void vac_update_datfrozenxid | ( | void | ) |
Definition at line 1351 of file vacuum.c.
References AccessShareLock, Assert, BTEqualStrategyNumber, DatabaseOidIndexId, elog, ERROR, ExclusiveLock, ForceTransactionIdLimitUpdate(), GetOldestMultiXactId(), GetOldestNonRemovableTransactionId(), GETSTRUCT, heap_copytuple(), heap_freetuple(), heap_inplace_update(), HeapTupleIsValid, InvalidOid, sort-test::key, LockDatabaseFrozenIds(), MultiXactIdIsValid, MultiXactIdPrecedes(), MyDatabaseId, ObjectIdGetDatum, ReadNewTransactionId(), ReadNextMultiXactId(), RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), TransactionIdIsNormal, TransactionIdIsValid, TransactionIdPrecedes(), and vac_truncate_clog().
Referenced by do_autovacuum(), and vacuum().
void vac_update_relstats | ( | Relation | relation, |
BlockNumber | num_pages, | ||
double | num_tuples, | ||
BlockNumber | num_all_visible_pages, | ||
bool | hasindex, | ||
TransactionId | frozenxid, | ||
MultiXactId | minmulti, | ||
bool | in_outer_xact | ||
) |
Definition at line 1224 of file vacuum.c.
References elog, ERROR, GETSTRUCT, heap_inplace_update(), HeapTupleIsValid, MultiXactIdIsValid, MultiXactIdPrecedes(), ObjectIdGetDatum, RelationData::rd_rules, ReadNewTransactionId(), ReadNextMultiXactId(), RelationGetRelid, RELOID, RowExclusiveLock, SearchSysCacheCopy1, table_close(), table_open(), TransactionIdIsNormal, TransactionIdPrecedes(), and RelationData::trigdesc.
Referenced by do_analyze_rel(), heap_vacuum_rel(), and update_index_statistics().
void vacuum | ( | List * | relations, |
VacuumParams * | params, | ||
BufferAccessStrategy | bstrategy, | ||
bool | isTopLevel | ||
) |
Definition at line 272 of file vacuum.c.
References ActiveSnapshotSet(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, analyze_rel(), Assert, BAS_VACUUM, CommandCounterIncrement(), CommitTransactionCommand(), cur, ereport, errcode(), errmsg(), ERROR, expand_vacuum_rel(), get_all_vacuum_rels(), GetAccessStrategy(), GetTransactionSnapshot(), IsAutoVacuumWorkerProcess(), IsInTransactionBlock(), lfirst_node, list_concat(), list_length(), MemoryContextDelete(), MemoryContextSwitchTo(), NIL, VacuumRelation::oid, VacuumParams::options, PG_END_TRY, PG_FINALLY, PG_TRY, pgstat_vacuum_stat(), PopActiveSnapshot(), PortalContext, PreventInTransactionBlock(), PushActiveSnapshot(), VacuumRelation::relation, StartTransactionCommand(), VacuumRelation::va_cols, vac_update_datfrozenxid(), VACOPT_ANALYZE, VACOPT_DISABLE_PAGE_SKIPPING, VACOPT_FULL, VACOPT_VACUUM, vacuum_rel(), VacuumCostActive, VacuumCostBalance, VacuumCostBalanceLocal, VacuumCostDelay, VacuumPageDirty, VacuumPageHit, and VacuumPageMiss.
Referenced by autovacuum_do_vac_analyze(), and ExecVacuum().
void vacuum_delay_point | ( | void | ) |
Definition at line 2047 of file vacuum.c.
References AutoVacuumUpdateDelay(), CHECK_FOR_INTERRUPTS, compute_parallel_delay(), InterruptPending, pg_usleep(), pgstat_report_wait_end(), pgstat_report_wait_start(), VacuumCostActive, VacuumCostBalance, VacuumCostDelay, VacuumCostLimit, and WAIT_EVENT_VACUUM_DELAY.
Referenced by acquire_sample_rows(), blbulkdelete(), blvacuumcleanup(), btvacuumpage(), compute_array_stats(), compute_distinct_stats(), compute_index_stats(), compute_range_stats(), compute_scalar_stats(), compute_trivial_stats(), compute_tsvector_stats(), file_acquire_sample_rows(), ginbulkdelete(), ginInsertCleanup(), ginvacuumcleanup(), gistvacuumpage(), hashbucketcleanup(), lazy_scan_heap(), lazy_vacuum_heap(), spgprocesspending(), and spgvacuumpage().
bool vacuum_is_relation_owner | ( | Oid | relid, |
Form_pg_class | reltuple, | ||
bits32 | options | ||
) |
Definition at line 533 of file vacuum.c.
References Assert, ereport, errmsg(), GetUserId(), MyDatabaseId, NameStr, pg_class_ownercheck(), pg_database_ownercheck(), relname, VACOPT_ANALYZE, VACOPT_VACUUM, and WARNING.
Referenced by analyze_rel(), expand_vacuum_rel(), get_all_vacuum_rels(), and vacuum_rel().
Relation vacuum_open_relation | ( | Oid | relid, |
RangeVar * | relation, | ||
bits32 | options, | ||
bool | verbose, | ||
LOCKMODE | lmode | ||
) |
Definition at line 607 of file vacuum.c.
References Assert, ConditionalLockRelationOid(), elevel, ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errmsg(), IsAutoVacuumWorkerProcess(), LOG, NoLock, RangeVar::relname, try_relation_open(), VACOPT_ANALYZE, VACOPT_SKIP_LOCKED, VACOPT_VACUUM, and WARNING.
Referenced by analyze_rel(), and vacuum_rel().
void vacuum_set_xid_limits | ( | Relation | rel, |
int | freeze_min_age, | ||
int | freeze_table_age, | ||
int | multixact_freeze_min_age, | ||
int | multixact_freeze_table_age, | ||
TransactionId * | oldestXmin, | ||
TransactionId * | freezeLimit, | ||
TransactionId * | xidFullScanLimit, | ||
MultiXactId * | multiXactCutoff, | ||
MultiXactId * | mxactFullScanLimit | ||
) |
Definition at line 931 of file vacuum.c.
References Assert, autovacuum_freeze_max_age, ereport, errhint(), errmsg(), FirstMultiXactId, FirstNormalTransactionId, GetOldestMultiXactId(), GetOldestNonRemovableTransactionId(), Min, MultiXactIdPrecedes(), MultiXactMemberFreezeThreshold(), OldSnapshotThresholdActive(), ReadNewTransactionId(), ReadNextMultiXactId(), SetOldSnapshotThresholdTimestamp(), TransactionIdIsNormal, TransactionIdLimitedForOldSnapshots(), TransactionIdPrecedes(), vacuum_freeze_min_age, vacuum_freeze_table_age, vacuum_multixact_freeze_min_age, vacuum_multixact_freeze_table_age, and WARNING.
Referenced by copy_table_data(), and heap_vacuum_rel().
PGDLLIMPORT int default_statistics_target |
Definition at line 81 of file analyze.c.
Referenced by multirange_typanalyze(), range_typanalyze(), statext_compute_stattarget(), std_typanalyze(), and ts_typanalyze().
int vacuum_freeze_min_age |
Definition at line 61 of file vacuum.c.
Referenced by do_autovacuum(), and vacuum_set_xid_limits().
int vacuum_freeze_table_age |
Definition at line 62 of file vacuum.c.
Referenced by do_autovacuum(), and vacuum_set_xid_limits().
int vacuum_multixact_freeze_min_age |
Definition at line 63 of file vacuum.c.
Referenced by do_autovacuum(), and vacuum_set_xid_limits().
int vacuum_multixact_freeze_table_age |
Definition at line 64 of file vacuum.c.
Referenced by do_autovacuum(), and vacuum_set_xid_limits().
pg_atomic_uint32* VacuumActiveNWorkers |
Definition at line 77 of file vacuum.c.
Referenced by lazy_parallel_vacuum_indexes(), parallel_vacuum_index(), parallel_vacuum_main(), and vacuum_indexes_leader().
int VacuumCostBalanceLocal |
Definition at line 78 of file vacuum.c.
Referenced by compute_parallel_delay(), lazy_parallel_vacuum_indexes(), parallel_vacuum_main(), and vacuum().
pg_atomic_uint32* VacuumSharedCostBalance |
Definition at line 76 of file vacuum.c.
Referenced by lazy_parallel_vacuum_indexes(), and parallel_vacuum_main().