PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/amapi.h"
#include "access/table.h"
#include "access/xact.h"
#include "commands/progress.h"
#include "commands/vacuum.h"
#include "executor/instrument.h"
#include "optimizer/paths.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "tcop/tcopprot.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | PVShared |
struct | PVIndStats |
struct | ParallelVacuumState |
Macros | |
#define | PARALLEL_VACUUM_KEY_SHARED 1 |
#define | PARALLEL_VACUUM_KEY_QUERY_TEXT 2 |
#define | PARALLEL_VACUUM_KEY_BUFFER_USAGE 3 |
#define | PARALLEL_VACUUM_KEY_WAL_USAGE 4 |
#define | PARALLEL_VACUUM_KEY_INDEX_STATS 5 |
Typedefs | |
typedef struct PVShared | PVShared |
typedef enum PVIndVacStatus | PVIndVacStatus |
typedef struct PVIndStats | PVIndStats |
Enumerations | |
enum | PVIndVacStatus { PARALLEL_INDVAC_STATUS_INITIAL = 0 , PARALLEL_INDVAC_STATUS_NEED_BULKDELETE , PARALLEL_INDVAC_STATUS_NEED_CLEANUP , PARALLEL_INDVAC_STATUS_COMPLETED } |
#define PARALLEL_VACUUM_KEY_BUFFER_USAGE 3 |
Definition at line 49 of file vacuumparallel.c.
#define PARALLEL_VACUUM_KEY_INDEX_STATS 5 |
Definition at line 51 of file vacuumparallel.c.
#define PARALLEL_VACUUM_KEY_QUERY_TEXT 2 |
Definition at line 48 of file vacuumparallel.c.
#define PARALLEL_VACUUM_KEY_SHARED 1 |
Definition at line 47 of file vacuumparallel.c.
#define PARALLEL_VACUUM_KEY_WAL_USAGE 4 |
Definition at line 50 of file vacuumparallel.c.
typedef struct PVIndStats PVIndStats |
typedef enum PVIndVacStatus PVIndVacStatus |
enum PVIndVacStatus |
Enumerator | |
---|---|
PARALLEL_INDVAC_STATUS_INITIAL | |
PARALLEL_INDVAC_STATUS_NEED_BULKDELETE | |
PARALLEL_INDVAC_STATUS_NEED_CLEANUP | |
PARALLEL_INDVAC_STATUS_COMPLETED |
Definition at line 125 of file vacuumparallel.c.
void parallel_vacuum_bulkdel_all_indexes | ( | ParallelVacuumState * | pvs, |
long | num_table_tuples, | ||
int | num_index_scans | ||
) |
Definition at line 501 of file vacuumparallel.c.
References Assert, PVShared::estimated_count, IsParallelWorker, parallel_vacuum_process_all_indexes(), PVShared::reltuples, and ParallelVacuumState::shared.
Referenced by lazy_vacuum_all_indexes().
void parallel_vacuum_cleanup_all_indexes | ( | ParallelVacuumState * | pvs, |
long | num_table_tuples, | ||
int | num_index_scans, | ||
bool | estimated_count | ||
) |
Definition at line 520 of file vacuumparallel.c.
References Assert, PVShared::estimated_count, IsParallelWorker, parallel_vacuum_process_all_indexes(), PVShared::reltuples, and ParallelVacuumState::shared.
Referenced by lazy_cleanup_all_indexes().
|
static |
Definition at line 550 of file vacuumparallel.c.
References IndexAmRoutine::amparallelvacuumoptions, i, IsUnderPostmaster, Max, max_parallel_maintenance_workers, Min, min_parallel_index_scan_size, RelationData::rd_indam, RelationGetNumberOfBlocks, VACUUM_OPTION_NO_PARALLEL, VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, and VACUUM_OPTION_PARALLEL_COND_CLEANUP.
Referenced by parallel_vacuum_init().
void parallel_vacuum_end | ( | ParallelVacuumState * | pvs, |
IndexBulkDeleteResult ** | istats | ||
) |
Definition at line 436 of file vacuumparallel.c.
References Assert, ParallelVacuumState::dead_items, DestroyParallelContext(), ExitParallelMode(), i, ParallelVacuumState::indstats, IsParallelWorker, PVIndStats::istat, PVIndStats::istat_updated, ParallelVacuumState::nindexes, palloc0(), ParallelVacuumState::pcxt, pfree(), TidStoreDestroy(), and ParallelVacuumState::will_parallel_vacuum.
Referenced by dead_items_cleanup().
|
static |
Definition at line 1108 of file vacuumparallel.c.
References arg, errcontext, ParallelVacuumState::indname, PARALLEL_INDVAC_STATUS_COMPLETED, PARALLEL_INDVAC_STATUS_INITIAL, PARALLEL_INDVAC_STATUS_NEED_BULKDELETE, PARALLEL_INDVAC_STATUS_NEED_CLEANUP, ParallelVacuumState::relname, ParallelVacuumState::relnamespace, and ParallelVacuumState::status.
Referenced by parallel_vacuum_main().
TidStore* parallel_vacuum_get_dead_items | ( | ParallelVacuumState * | pvs, |
VacDeadItemsInfo ** | dead_items_info_p | ||
) |
Definition at line 467 of file vacuumparallel.c.
References ParallelVacuumState::dead_items, PVShared::dead_items_info, and ParallelVacuumState::shared.
Referenced by dead_items_alloc().
|
static |
Definition at line 952 of file vacuumparallel.c.
References IndexAmRoutine::amparallelvacuumoptions, RelationData::rd_indam, vacuum(), VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, and VACUUM_OPTION_PARALLEL_COND_CLEANUP.
Referenced by parallel_vacuum_process_all_indexes().
ParallelVacuumState* parallel_vacuum_init | ( | Relation | rel, |
Relation * | indrels, | ||
int | nindexes, | ||
int | nrequested_workers, | ||
int | vac_work_mem, | ||
int | elevel, | ||
BufferAccessStrategy | bstrategy | ||
) |
Definition at line 243 of file vacuumparallel.c.
References PVShared::active_nworkers, IndexAmRoutine::amparallelvacuumoptions, IndexAmRoutine::amusemaintenanceworkmem, Assert, ParallelVacuumState::bstrategy, ParallelVacuumState::buffer_usage, PVShared::cost_balance, CreateParallelContext(), ParallelVacuumState::dead_items, PVShared::dead_items_dsa_handle, PVShared::dead_items_handle, PVShared::dead_items_info, debug_query_string, dsa_get_handle(), PVShared::elevel, EnterParallelMode(), ParallelContext::estimator, GetAccessStrategyBufferCount(), ParallelVacuumState::heaprel, i, PVShared::idx, ParallelVacuumState::indrels, ParallelVacuumState::indstats, InitializeParallelDSM(), LWTRANCHE_PARALLEL_VACUUM_DSA, maintenance_work_mem, PVShared::maintenance_work_mem_worker, VacDeadItemsInfo::max_bytes, MemSet, Min, mul_size(), ParallelVacuumState::nindexes, ParallelVacuumState::nindexes_parallel_bulkdel, ParallelVacuumState::nindexes_parallel_cleanup, ParallelVacuumState::nindexes_parallel_condcleanup, ParallelContext::nworkers, palloc0(), parallel_vacuum_compute_workers(), PARALLEL_VACUUM_KEY_BUFFER_USAGE, PARALLEL_VACUUM_KEY_INDEX_STATS, PARALLEL_VACUUM_KEY_QUERY_TEXT, PARALLEL_VACUUM_KEY_SHARED, PARALLEL_VACUUM_KEY_WAL_USAGE, ParallelVacuumState::pcxt, pfree(), pg_atomic_init_u32(), pgstat_get_my_query_id(), PVShared::queryid, RelationData::rd_indam, RelationGetRelid, PVShared::relid, PVShared::ring_nbuffers, ParallelVacuumState::shared, shm_toc_allocate(), shm_toc_estimate_chunk, shm_toc_estimate_keys, shm_toc_insert(), TidStoreCreateShared(), TidStoreGetDSA(), TidStoreGetHandle(), ParallelContext::toc, VACUUM_OPTION_MAX_VALID_VALUE, VACUUM_OPTION_PARALLEL_BULKDEL, VACUUM_OPTION_PARALLEL_CLEANUP, VACUUM_OPTION_PARALLEL_COND_CLEANUP, ParallelVacuumState::wal_usage, and ParallelVacuumState::will_parallel_vacuum.
Referenced by dead_items_alloc().
void parallel_vacuum_main | ( | dsm_segment * | seg, |
shm_toc * | toc | ||
) |
Definition at line 990 of file vacuumparallel.c.
References PVShared::active_nworkers, ErrorContextCallback::arg, Assert, BAS_VACUUM, ParallelVacuumState::bstrategy, ErrorContextCallback::callback, PVShared::cost_balance, ParallelVacuumState::dead_items, PVShared::dead_items_dsa_handle, PVShared::dead_items_handle, DEBUG1, debug_query_string, elog, error_context_stack, FreeAccessStrategy(), get_namespace_name(), GetAccessStrategyWithSize(), ParallelVacuumState::heaprel, ParallelVacuumState::indname, ParallelVacuumState::indrels, ParallelVacuumState::indstats, InstrEndParallelQuery(), InstrStartParallelQuery(), maintenance_work_mem, PVShared::maintenance_work_mem_worker, MyProc, ParallelVacuumState::nindexes, PARALLEL_INDVAC_STATUS_INITIAL, parallel_vacuum_error_callback(), PARALLEL_VACUUM_KEY_BUFFER_USAGE, PARALLEL_VACUUM_KEY_INDEX_STATS, PARALLEL_VACUUM_KEY_QUERY_TEXT, PARALLEL_VACUUM_KEY_SHARED, PARALLEL_VACUUM_KEY_WAL_USAGE, parallel_vacuum_process_safe_indexes(), ParallelWorkerNumber, pgstat_report_activity(), pgstat_report_query_id(), ErrorContextCallback::previous, PROC_IN_VACUUM, pstrdup(), PVShared::queryid, RelationGetNamespace, RelationGetRelationName, PVShared::relid, ParallelVacuumState::relname, ParallelVacuumState::relnamespace, PVShared::ring_nbuffers, RowExclusiveLock, ParallelVacuumState::shared, ShareUpdateExclusiveLock, shm_toc_lookup(), STATE_RUNNING, ParallelVacuumState::status, PGPROC::statusFlags, table_close(), table_open(), TidStoreAttach(), TidStoreDetach(), vac_close_indexes(), vac_open_indexes(), VacuumActiveNWorkers, VacuumCostBalance, VacuumCostBalanceLocal, VacuumSharedCostBalance, and VacuumUpdateCosts().
|
static |
Definition at line 612 of file vacuumparallel.c.
References PVShared::active_nworkers, Assert, ParallelVacuumState::buffer_usage, PVShared::cost_balance, PVShared::elevel, elog, ereport, errmsg(), ERROR, i, PVShared::idx, ParallelVacuumState::indrels, ParallelVacuumState::indstats, InstrAccumParallelQuery(), IsParallelWorker, LaunchParallelWorkers(), Min, ngettext, ParallelVacuumState::nindexes, ParallelVacuumState::nindexes_parallel_bulkdel, ParallelVacuumState::nindexes_parallel_cleanup, ParallelVacuumState::nindexes_parallel_condcleanup, ParallelContext::nworkers, ParallelContext::nworkers_launched, PARALLEL_INDVAC_STATUS_COMPLETED, PARALLEL_INDVAC_STATUS_INITIAL, PARALLEL_INDVAC_STATUS_NEED_BULKDELETE, PARALLEL_INDVAC_STATUS_NEED_CLEANUP, parallel_vacuum_index_is_parallel_safe(), parallel_vacuum_process_safe_indexes(), parallel_vacuum_process_unsafe_indexes(), PVIndStats::parallel_workers_can_process, ParallelVacuumState::pcxt, pg_atomic_read_u32(), pg_atomic_write_u32(), ReinitializeParallelDSM(), ReinitializeParallelWorkers(), RelationGetRelationName, ParallelVacuumState::shared, PVIndStats::status, vacuum(), VacuumActiveNWorkers, VacuumCostBalance, VacuumCostBalanceLocal, VacuumSharedCostBalance, WaitForParallelWorkersToFinish(), ParallelVacuumState::wal_usage, and ParallelVacuumState::will_parallel_vacuum.
Referenced by parallel_vacuum_bulkdel_all_indexes(), and parallel_vacuum_cleanup_all_indexes().
|
static |
Definition at line 866 of file vacuumparallel.c.
References IndexVacuumInfo::analyze_only, ParallelVacuumState::bstrategy, ParallelVacuumState::dead_items, PVShared::dead_items_info, DEBUG2, elog, ERROR, PVShared::estimated_count, IndexVacuumInfo::estimated_count, ParallelVacuumState::heaprel, IndexVacuumInfo::heaprel, IndexVacuumInfo::index, ParallelVacuumState::indname, PVIndStats::istat, PVIndStats::istat_updated, IndexVacuumInfo::message_level, IndexVacuumInfo::num_heap_tuples, PARALLEL_INDVAC_STATUS_COMPLETED, PARALLEL_INDVAC_STATUS_NEED_BULKDELETE, PARALLEL_INDVAC_STATUS_NEED_CLEANUP, pfree(), pgstat_progress_parallel_incr_param(), PROGRESS_VACUUM_INDEXES_PROCESSED, pstrdup(), RelationGetRelationName, PVShared::reltuples, IndexVacuumInfo::report_progress, ParallelVacuumState::shared, PVIndStats::status, ParallelVacuumState::status, IndexVacuumInfo::strategy, vac_bulkdel_one_index(), and vac_cleanup_one_index().
Referenced by parallel_vacuum_process_safe_indexes(), and parallel_vacuum_process_unsafe_indexes().
|
static |
Definition at line 775 of file vacuumparallel.c.
References idx(), PVShared::idx, ParallelVacuumState::indrels, ParallelVacuumState::indstats, ParallelVacuumState::nindexes, parallel_vacuum_process_one_index(), PVIndStats::parallel_workers_can_process, pg_atomic_add_fetch_u32(), pg_atomic_fetch_add_u32(), pg_atomic_sub_fetch_u32(), ParallelVacuumState::shared, and VacuumActiveNWorkers.
Referenced by parallel_vacuum_main(), and parallel_vacuum_process_all_indexes().
|
static |
Definition at line 829 of file vacuumparallel.c.
References Assert, i, ParallelVacuumState::indrels, ParallelVacuumState::indstats, IsParallelWorker, ParallelVacuumState::nindexes, parallel_vacuum_process_one_index(), PVIndStats::parallel_workers_can_process, pg_atomic_add_fetch_u32(), pg_atomic_sub_fetch_u32(), and VacuumActiveNWorkers.
Referenced by parallel_vacuum_process_all_indexes().
void parallel_vacuum_reset_dead_items | ( | ParallelVacuumState * | pvs | ) |
Definition at line 475 of file vacuumparallel.c.
References ParallelVacuumState::dead_items, PVShared::dead_items_dsa_handle, PVShared::dead_items_handle, PVShared::dead_items_info, dsa_get_handle(), LWTRANCHE_PARALLEL_VACUUM_DSA, VacDeadItemsInfo::max_bytes, VacDeadItemsInfo::num_items, ParallelVacuumState::shared, TidStoreCreateShared(), TidStoreDestroy(), TidStoreGetDSA(), and TidStoreGetHandle().
Referenced by dead_items_reset().