|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/nbtree.h"#include "access/parallel.h"#include "access/relscan.h"#include "access/table.h"#include "access/tableam.h"#include "access/xact.h"#include "catalog/index.h"#include "commands/progress.h"#include "executor/instrument.h"#include "miscadmin.h"#include "pgstat.h"#include "storage/bulk_write.h"#include "tcop/tcopprot.h"#include "utils/rel.h"#include "utils/sortsupport.h"#include "utils/tuplesort.h"
Go to the source code of this file.
Data Structures | |
| struct | BTSpool |
| struct | BTShared |
| struct | BTLeader |
| struct | BTBuildState |
| struct | BTPageState |
| struct | BTWriteState |
Macros | |
| #define | PARALLEL_KEY_BTREE_SHARED UINT64CONST(0xA000000000000001) |
| #define | PARALLEL_KEY_TUPLESORT UINT64CONST(0xA000000000000002) |
| #define | PARALLEL_KEY_TUPLESORT_SPOOL2 UINT64CONST(0xA000000000000003) |
| #define | PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xA000000000000004) |
| #define | PARALLEL_KEY_WAL_USAGE UINT64CONST(0xA000000000000005) |
| #define | PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xA000000000000006) |
| #define | ParallelTableScanFromBTShared(shared) (ParallelTableScanDesc) ((char *) (shared) + BUFFERALIGN(sizeof(BTShared))) |
| #define PARALLEL_KEY_BTREE_SHARED UINT64CONST(0xA000000000000001) |
| #define PARALLEL_KEY_BUFFER_USAGE UINT64CONST(0xA000000000000006) |
| #define PARALLEL_KEY_QUERY_TEXT UINT64CONST(0xA000000000000004) |
| #define PARALLEL_KEY_TUPLESORT UINT64CONST(0xA000000000000002) |
| #define PARALLEL_KEY_TUPLESORT_SPOOL2 UINT64CONST(0xA000000000000003) |
| #define PARALLEL_KEY_WAL_USAGE UINT64CONST(0xA000000000000005) |
| #define ParallelTableScanFromBTShared | ( | shared | ) | (ParallelTableScanDesc) ((char *) (shared) + BUFFERALIGN(sizeof(BTShared))) |
Definition at line 162 of file nbtsort.c.
|
static |
Definition at line 1396 of file nbtsort.c.
References _bt_end_parallel(), _bt_leader_participate_as_worker(), _bt_parallel_estimate_shared(), Assert, BTShared::brokenhotchain, BTLeader::btshared, BTLeader::bufferusage, ConditionVariableInit(), CreateParallelContext(), debug_query_string, DestroyParallelContext(), EnterParallelMode(), ParallelContext::estimator, ExitParallelMode(), fb(), GetTransactionSnapshot(), BTShared::havedead, BTShared::heaprelid, BTShared::indexrelid, BTShared::indtuples, InitializeParallelDSM(), BTShared::isconcurrent, IsMVCCSnapshot, BTShared::isunique, LaunchParallelWorkers(), mul_size(), BTShared::mutex, BTShared::nparticipantsdone, BTLeader::nparticipanttuplesorts, BTShared::nulls_not_distinct, ParallelContext::nworkers, ParallelContext::nworkers_launched, palloc0_object, PARALLEL_KEY_BTREE_SHARED, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_QUERY_TEXT, PARALLEL_KEY_TUPLESORT, PARALLEL_KEY_TUPLESORT_SPOOL2, PARALLEL_KEY_WAL_USAGE, ParallelTableScanFromBTShared, BTLeader::pcxt, pgstat_get_my_query_id(), BTShared::queryid, RegisterSnapshot(), RelationGetRelid, BTShared::reltuples, BTShared::scantuplesortstates, ParallelContext::seg, BTLeader::sharedsort, BTLeader::sharedsort2, shm_toc_allocate(), shm_toc_estimate_chunk, shm_toc_estimate_keys, shm_toc_insert(), BTLeader::snapshot, SnapshotAny, SpinLockInit, table_parallelscan_initialize(), ParallelContext::toc, tuplesort_estimate_shared(), tuplesort_initialize_shared(), UnregisterSnapshot(), WaitForParallelWorkersToAttach(), BTLeader::walusage, and BTShared::workersdonecv.
Referenced by _bt_spools_heapscan().
|
static |
Definition at line 609 of file nbtsort.c.
References _bt_pageinit(), BTP_LEAF, BTPageGetOpaque, BTPageOpaqueData::btpo_cycleid, BTPageOpaqueData::btpo_flags, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_next, BTPageOpaqueData::btpo_prev, buf, fb(), P_NONE, and smgr_bulk_get_buf().
Referenced by _bt_buildadd(), and _bt_pagestate().
|
static |
Definition at line 638 of file nbtsort.c.
References buf, fb(), and smgr_bulk_write().
Referenced by _bt_buildadd(), and _bt_uppershutdown().
|
static |
Definition at line 580 of file nbtsort.c.
References _bt_spool(), fb(), and values.
Referenced by _bt_parallel_scan_and_sort(), and _bt_spools_heapscan().
|
static |
Definition at line 786 of file nbtsort.c.
References _bt_blnewpage(), _bt_blwritepage(), _bt_buildadd(), _bt_check_third_page(), _bt_pagestate(), _bt_sortaddtup(), _bt_truncate(), Assert, BTMaxItemSize, BTPageGetOpaque, BTreeTupleGetNAtts, BTreeTupleSetDownLink(), BTreeTupleSetNAtts(), CHECK_FOR_INTERRUPTS, CopyIndexTuple(), elog, ERROR, fb(), IndexRelationGetNumberOfKeyAttributes, IndexTupleSize(), ItemIdGetLength, ItemIdSetUnused, MAXALIGN, OffsetNumberNext, OffsetNumberPrev, P_FIRSTKEY, P_HIKEY, P_LEFTMOST, P_NONE, PageGetFreeSpace(), PageGetItem(), PageGetItemId(), PageIndexTupleOverwrite(), palloc0_object, pfree(), and unlikely.
Referenced by _bt_buildadd(), _bt_load(), _bt_sort_dedup_finish_pending(), and _bt_uppershutdown().
Definition at line 1608 of file nbtsort.c.
References BTLeader::bufferusage, DestroyParallelContext(), ExitParallelMode(), i, InstrAccumParallelQuery(), IsMVCCSnapshot, ParallelContext::nworkers_launched, BTLeader::pcxt, BTLeader::snapshot, UnregisterSnapshot(), WaitForParallelWorkersToFinish(), and BTLeader::walusage.
Referenced by _bt_begin_parallel(), and btbuild().
|
static |
Definition at line 1688 of file nbtsort.c.
References _bt_parallel_scan_and_sort(), BTLeader::btshared, fb(), BTShared::isunique, log_btree_build_stats, maintenance_work_mem, BTLeader::nparticipanttuplesorts, palloc0_object, ResetUsage(), BTLeader::sharedsort, BTLeader::sharedsort2, and ShowUsage().
Referenced by _bt_begin_parallel().
Definition at line 539 of file nbtsort.c.
References _bt_allequalimage(), _bt_load(), _bt_mkscankey(), BTREE_METAPAGE, fb(), log_btree_build_stats, pgstat_progress_update_param(), PROGRESS_BTREE_PHASE_LEAF_LOAD, PROGRESS_BTREE_PHASE_PERFORMSORT_1, PROGRESS_BTREE_PHASE_PERFORMSORT_2, PROGRESS_CREATEIDX_SUBPHASE, ResetUsage(), ShowUsage(), and tuplesort_performsort().
Referenced by btbuild().
|
static |
Definition at line 1136 of file nbtsort.c.
References _bt_buildadd(), _bt_dedup_save_htid(), _bt_dedup_start_pending(), _bt_keep_natts_fast(), _bt_pagestate(), _bt_sort_dedup_finish_pending(), _bt_uppershutdown(), ApplySortComparator(), Assert, BTGetDeduplicateItems, BTMaxItemSize, compare(), CopyIndexTuple(), CurrentMemoryContext, fb(), i, index_getattr(), INDEX_SIZE_MASK, IndexRelationGetNumberOfKeyAttributes, InvalidOffsetNumber, ItemPointerCompare(), MAIN_FORKNUM, MAXALIGN_DOWN, merge(), palloc(), palloc0_array, palloc_object, pfree(), pgstat_progress_update_param(), PrepareSortSupportFromIndexRel(), PROGRESS_CREATEIDX_TUPLES_DONE, RelationGetDescr, SK_BT_DESC, SK_BT_NULLS_FIRST, smgr_bulk_finish(), smgr_bulk_start_rel(), IndexTupleData::t_tid, and tuplesort_getindextuple().
Referenced by _bt_leafbuild().
|
static |
Definition at line 649 of file nbtsort.c.
References _bt_blnewpage(), BTGetTargetPageFreeSpace, BTREE_NONLEAF_FILLFACTOR, fb(), P_HIKEY, and palloc0_object.
Referenced by _bt_buildadd(), and _bt_load().
| void _bt_parallel_build_main | ( | dsm_segment * | seg, |
| shm_toc * | toc | ||
| ) |
Definition at line 1741 of file nbtsort.c.
References _bt_parallel_scan_and_sort(), AccessExclusiveLock, Assert, debug_query_string, fb(), BTShared::heaprelid, index_close(), index_open(), BTShared::indexrelid, InstrEndParallelQuery(), InstrStartParallelQuery(), BTShared::isconcurrent, BTShared::isunique, log_btree_build_stats, maintenance_work_mem, MyProc, BTShared::nulls_not_distinct, palloc0_object, PARALLEL_KEY_BTREE_SHARED, PARALLEL_KEY_BUFFER_USAGE, PARALLEL_KEY_QUERY_TEXT, PARALLEL_KEY_TUPLESORT, PARALLEL_KEY_TUPLESORT_SPOOL2, PARALLEL_KEY_WAL_USAGE, ParallelWorkerNumber, pgstat_report_activity(), pgstat_report_query_id(), PROC_IN_SAFE_IC, BTShared::queryid, ResetUsage(), RowExclusiveLock, BTShared::scantuplesortstates, ShareLock, ShareUpdateExclusiveLock, shm_toc_lookup(), ShowUsage(), STATE_RUNNING, PGPROC::statusFlags, table_close(), table_open(), and tuplesort_attach_shared().
Definition at line 1634 of file nbtsort.c.
References add_size(), BUFFERALIGN, and table_parallelscan_estimate().
Referenced by _bt_begin_parallel().
|
static |
Definition at line 1654 of file nbtsort.c.
References BTShared::brokenhotchain, ConditionVariableCancelSleep(), ConditionVariableSleep(), fb(), BTShared::havedead, BTShared::indtuples, BTShared::mutex, BTShared::nparticipantsdone, BTShared::reltuples, SpinLockAcquire, SpinLockRelease, and BTShared::workersdonecv.
Referenced by _bt_spools_heapscan().
|
static |
Definition at line 1866 of file nbtsort.c.
References _bt_build_callback(), BTShared::brokenhotchain, BuildIndexInfo(), ConditionVariableSignal(), fb(), BTShared::havedead, IndexInfo::ii_BrokenHotChain, IndexInfo::ii_Concurrent, BTShared::indtuples, BTShared::isconcurrent, BTShared::isunique, Min, BTShared::mutex, BTShared::nparticipantsdone, BTShared::nulls_not_distinct, palloc0_object, ParallelTableScanFromBTShared, pgstat_progress_update_param(), progress, PROGRESS_BTREE_PHASE_PERFORMSORT_1, PROGRESS_BTREE_PHASE_PERFORMSORT_2, PROGRESS_CREATEIDX_SUBPHASE, BTShared::reltuples, SpinLockAcquire, SpinLockRelease, table_beginscan_parallel(), table_index_build_scan(), tuplesort_begin_index_btree(), tuplesort_end(), TUPLESORT_NONE, tuplesort_performsort(), work_mem, and BTShared::workersdonecv.
Referenced by _bt_leader_participate_as_worker(), and _bt_parallel_build_main().
Definition at line 686 of file nbtsort.c.
References Assert, fb(), OffsetNumberNext, P_FIRSTKEY, P_HIKEY, PageGetItemId(), and PageGetMaxOffsetNumber().
Referenced by _bt_uppershutdown().
|
static |
Definition at line 1030 of file nbtsort.c.
References _bt_buildadd(), _bt_form_posting(), Assert, BTreeTupleGetPostingOffset(), fb(), IndexTupleSize(), and pfree().
Referenced by _bt_load().
|
static |
Definition at line 717 of file nbtsort.c.
References BTreeTupleSetNAtts(), elog, ERROR, fb(), InvalidOffsetNumber, PageAddItem, and IndexTupleData::t_info.
Referenced by _bt_buildadd().
|
static |
Definition at line 528 of file nbtsort.c.
References fb(), tuplesort_putindextuplevalues(), and values.
Referenced by _bt_build_callback().
Definition at line 518 of file nbtsort.c.
References fb(), pfree(), and tuplesort_end().
Referenced by _bt_spools_heapscan(), and btbuild().
|
static |
Definition at line 366 of file nbtsort.c.
References _bt_begin_parallel(), _bt_build_callback(), _bt_parallel_heapscan(), _bt_spooldestroy(), fb(), IndexInfo::ii_BrokenHotChain, IndexInfo::ii_Concurrent, IndexInfo::ii_NullsNotDistinct, IndexInfo::ii_ParallelWorkers, IndexInfo::ii_Unique, maintenance_work_mem, palloc0_object, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PROGRESS_BTREE_PHASE_INDEXBUILD_TABLESCAN, PROGRESS_CREATEIDX_SUBPHASE, PROGRESS_CREATEIDX_TUPLES_TOTAL, PROGRESS_SCAN_BLOCKS_DONE, PROGRESS_SCAN_BLOCKS_TOTAL, table_index_build_scan(), tuplesort_begin_index_btree(), TUPLESORT_NONE, and work_mem.
Referenced by btbuild().
|
static |
Definition at line 1064 of file nbtsort.c.
References _bt_blwritepage(), _bt_buildadd(), _bt_initmetapage(), _bt_slideleft(), Assert, BTP_ROOT, BTPageGetOpaque, BTPageOpaqueData::btpo_flags, BTPageState::btps_blkno, BTPageState::btps_buf, BTPageState::btps_level, BTPageState::btps_lowkey, BTPageState::btps_next, BTREE_METAPAGE, BTreeTupleGetNAtts, BTreeTupleSetDownLink(), fb(), IndexRelationGetNumberOfKeyAttributes, P_LEFTMOST, P_NONE, pfree(), and smgr_bulk_get_buf().
Referenced by _bt_load().
| IndexBuildResult * btbuild | ( | Relation | heap, |
| Relation | index, | ||
| IndexInfo * | indexInfo | ||
| ) |
Definition at line 296 of file nbtsort.c.
References _bt_end_parallel(), _bt_leafbuild(), _bt_spooldestroy(), _bt_spools_heapscan(), elog, ERROR, fb(), IndexBuildResult::heap_tuples, IndexInfo::ii_NullsNotDistinct, IndexInfo::ii_Unique, IndexBuildResult::index_tuples, log_btree_build_stats, palloc_object, RelationGetNumberOfBlocks, RelationGetRelationName, ResetUsage(), and ShowUsage().
Referenced by bthandler().