PostgreSQL Source Code git master
|
#include "postgres.h"
#include "executor/execdebug.h"
#include "executor/nodeIncrementalSort.h"
#include "miscadmin.h"
#include "utils/lsyscache.h"
#include "utils/tuplesort.h"
Go to the source code of this file.
Macros | |
#define | INSTRUMENT_SORT_GROUP(node, groupName) |
#define | DEFAULT_MIN_GROUP_SIZE 32 |
#define | DEFAULT_MAX_FULL_SORT_GROUP_SIZE (2 * DEFAULT_MIN_GROUP_SIZE) |
Functions | |
static void | instrumentSortedGroup (IncrementalSortGroupInfo *groupInfo, Tuplesortstate *sortState) |
static void | preparePresortedCols (IncrementalSortState *node) |
static bool | isCurrentGroup (IncrementalSortState *node, TupleTableSlot *pivot, TupleTableSlot *tuple) |
static void | switchToPresortedPrefixMode (PlanState *pstate) |
static TupleTableSlot * | ExecIncrementalSort (PlanState *pstate) |
IncrementalSortState * | ExecInitIncrementalSort (IncrementalSort *node, EState *estate, int eflags) |
void | ExecEndIncrementalSort (IncrementalSortState *node) |
void | ExecReScanIncrementalSort (IncrementalSortState *node) |
void | ExecIncrementalSortEstimate (IncrementalSortState *node, ParallelContext *pcxt) |
void | ExecIncrementalSortInitializeDSM (IncrementalSortState *node, ParallelContext *pcxt) |
void | ExecIncrementalSortInitializeWorker (IncrementalSortState *node, ParallelWorkerContext *pwcxt) |
void | ExecIncrementalSortRetrieveInstrumentation (IncrementalSortState *node) |
#define DEFAULT_MAX_FULL_SORT_GROUP_SIZE (2 * DEFAULT_MIN_GROUP_SIZE) |
Definition at line 479 of file nodeIncrementalSort.c.
#define DEFAULT_MIN_GROUP_SIZE 32 |
Definition at line 467 of file nodeIncrementalSort.c.
#define INSTRUMENT_SORT_GROUP | ( | node, | |
groupName | |||
) |
Definition at line 98 of file nodeIncrementalSort.c.
void ExecEndIncrementalSort | ( | IncrementalSortState * | node | ) |
Definition at line 1077 of file nodeIncrementalSort.c.
References ExecDropSingleTupleTableSlot(), ExecEndNode(), IncrementalSortState::fullsort_state, IncrementalSortState::group_pivot, outerPlanState, IncrementalSortState::prefixsort_state, SO_printf, IncrementalSortState::transfer_tuple, and tuplesort_end().
Referenced by ExecEndNode().
|
static |
Definition at line 495 of file nodeIncrementalSort.c.
References Assert, IncrementalSortState::bound, IncrementalSortState::bound_Done, IncrementalSortState::bounded, castNode, CHECK_FOR_INTERRUPTS, DEFAULT_MAX_FULL_SORT_GROUP_SIZE, DEFAULT_MIN_GROUP_SIZE, EState::es_direction, ExecClearTuple(), ExecCopySlot(), ExecGetResultType(), ExecProcNode(), IncrementalSortState::execution_status, ForwardScanDirection, IncrementalSortState::fullsort_state, IncrementalSortState::group_pivot, INCSORT_LOADFULLSORT, INCSORT_LOADPREFIXSORT, INCSORT_READFULLSORT, INCSORT_READPREFIXSORT, INSTRUMENT_SORT_GROUP, INT64_FORMAT, isCurrentGroup(), Min, IncrementalSortState::n_fullsort_remaining, Sort::numCols, IncrementalSortState::outerNodeDone, outerPlanState, PlanState::plan, IncrementalSortState::prefixsort_state, preparePresortedCols(), ScanState::ps, PlanState::ps_ResultTupleSlot, ScanDirectionIsForward, SO1_printf, SO2_printf, SO_printf, IncrementalSort::sort, IncrementalSortState::ss, PlanState::state, switchToPresortedPrefixMode(), TupIsNull, TUPLESORT_ALLOWBOUNDED, tuplesort_begin_heap(), tuplesort_gettupleslot(), TUPLESORT_NONE, tuplesort_performsort(), tuplesort_puttupleslot(), tuplesort_reset(), tuplesort_set_bound(), tuplesort_used_bound(), and work_mem.
Referenced by ExecInitIncrementalSort().
void ExecIncrementalSortEstimate | ( | IncrementalSortState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 1173 of file nodeIncrementalSort.c.
References add_size(), ParallelContext::estimator, PlanState::instrument, mul_size(), ParallelContext::nworkers, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, size, and IncrementalSortState::ss.
Referenced by ExecParallelEstimate().
void ExecIncrementalSortInitializeDSM | ( | IncrementalSortState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 1194 of file nodeIncrementalSort.c.
References PlanState::instrument, SharedIncrementalSortInfo::num_workers, ParallelContext::nworkers, PlanState::plan, Plan::plan_node_id, ScanState::ps, IncrementalSortState::shared_info, shm_toc_allocate(), shm_toc_insert(), size, IncrementalSortState::ss, and ParallelContext::toc.
Referenced by ExecParallelInitializeDSM().
void ExecIncrementalSortInitializeWorker | ( | IncrementalSortState * | node, |
ParallelWorkerContext * | pwcxt | ||
) |
Definition at line 1219 of file nodeIncrementalSort.c.
References IncrementalSortState::am_worker, PlanState::plan, Plan::plan_node_id, ScanState::ps, IncrementalSortState::shared_info, shm_toc_lookup(), IncrementalSortState::ss, and ParallelWorkerContext::toc.
Referenced by ExecParallelInitializeWorker().
void ExecIncrementalSortRetrieveInstrumentation | ( | IncrementalSortState * | node | ) |
Definition at line 1233 of file nodeIncrementalSort.c.
References SharedIncrementalSortInfo::num_workers, palloc(), IncrementalSortState::shared_info, and size.
Referenced by ExecParallelRetrieveInstrumentation().
IncrementalSortState * ExecInitIncrementalSort | ( | IncrementalSort * | node, |
EState * | estate, | ||
int | eflags | ||
) |
Definition at line 976 of file nodeIncrementalSort.c.
References Assert, IncrementalSortState::bound_Done, IncrementalSortState::bounded, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecCreateScanSlotFromOuterPlan(), ExecGetResultType(), ExecIncrementalSort(), ExecInitNode(), ExecInitResultTupleSlotTL(), PlanState::ExecProcNode, IncrementalSortState::execution_status, IncrementalSortState::fullsort_state, IncrementalSortInfo::fullsortGroupInfo, IncrementalSortState::group_pivot, IncrementalSortGroupInfo::groupCount, IncrementalSortState::incsort_info, INCSORT_LOADFULLSORT, PlanState::instrument, makeNode, MakeSingleTupleTableSlot(), IncrementalSortGroupInfo::maxDiskSpaceUsed, IncrementalSortGroupInfo::maxMemorySpaceUsed, IncrementalSortState::n_fullsort_remaining, IncrementalSortState::outerNodeDone, outerPlan, outerPlanState, PlanState::plan, IncrementalSortState::prefixsort_state, IncrementalSortInfo::prefixsortGroupInfo, IncrementalSortState::presorted_keys, ScanState::ps, PlanState::ps_ProjInfo, SO_printf, IncrementalSortGroupInfo::sortMethods, IncrementalSortState::ss, PlanState::state, IncrementalSortGroupInfo::totalDiskSpaceUsed, IncrementalSortGroupInfo::totalMemorySpaceUsed, IncrementalSortState::transfer_tuple, and TTSOpsMinimalTuple.
Referenced by ExecInitNode().
void ExecReScanIncrementalSort | ( | IncrementalSortState * | node | ) |
Definition at line 1107 of file nodeIncrementalSort.c.
References IncrementalSortState::bound_Done, ExecClearTuple(), ExecReScan(), IncrementalSortState::execution_status, IncrementalSortState::fullsort_state, IncrementalSortState::group_pivot, INCSORT_LOADFULLSORT, IncrementalSortState::n_fullsort_remaining, IncrementalSortState::outerNodeDone, outerPlan, outerPlanState, IncrementalSortState::prefixsort_state, ScanState::ps, PlanState::ps_ResultTupleSlot, IncrementalSortState::ss, IncrementalSortState::transfer_tuple, and tuplesort_reset().
Referenced by ExecReScan().
|
static |
Definition at line 127 of file nodeIncrementalSort.c.
References IncrementalSortGroupInfo::groupCount, IncrementalSortGroupInfo::maxDiskSpaceUsed, IncrementalSortGroupInfo::maxMemorySpaceUsed, SORT_SPACE_TYPE_DISK, SORT_SPACE_TYPE_MEMORY, TuplesortInstrumentation::sortMethod, IncrementalSortGroupInfo::sortMethods, TuplesortInstrumentation::spaceType, TuplesortInstrumentation::spaceUsed, IncrementalSortGroupInfo::totalDiskSpaceUsed, IncrementalSortGroupInfo::totalMemorySpaceUsed, and tuplesort_get_stats().
|
static |
Definition at line 212 of file nodeIncrementalSort.c.
References PresortedKeyData::attno, castNode, DatumGetBool(), elog, ERROR, FunctionCallInvoke, i, sort-test::key, PlanState::plan, IncrementalSortState::presorted_keys, ScanState::ps, slot_getattr(), and IncrementalSortState::ss.
Referenced by ExecIncrementalSort(), and switchToPresortedPrefixMode().
|
static |
Definition at line 164 of file nodeIncrementalSort.c.
References castNode, CurrentMemoryContext, elog, ERROR, fmgr_info_cxt(), get_equality_op_for_ordering_op(), get_opcode(), i, InitFunctionCallInfoData, sort-test::key, IncrementalSort::nPresortedCols, OidIsValid, palloc(), palloc0(), PlanState::plan, IncrementalSortState::presorted_keys, ScanState::ps, SizeForFunctionCallInfo, IncrementalSort::sort, and IncrementalSortState::ss.
Referenced by ExecIncrementalSort().
|
static |
Definition at line 286 of file nodeIncrementalSort.c.
References IncrementalSortState::bound, IncrementalSortState::bound_Done, IncrementalSortState::bounded, castNode, EState::es_direction, ExecClearTuple(), ExecCopySlot(), ExecGetResultType(), IncrementalSortState::execution_status, IncrementalSortState::fullsort_state, IncrementalSortState::group_pivot, INCSORT_LOADPREFIXSORT, INCSORT_READPREFIXSORT, INSTRUMENT_SORT_GROUP, INT64_FORMAT, isCurrentGroup(), Min, IncrementalSortState::n_fullsort_remaining, IncrementalSort::nPresortedCols, Sort::numCols, outerPlanState, PlanState::plan, IncrementalSortState::prefixsort_state, ScanState::ps, ScanDirectionIsForward, SO1_printf, SO2_printf, SO_printf, IncrementalSort::sort, IncrementalSortState::ss, PlanState::state, IncrementalSortState::transfer_tuple, TupIsNull, TUPLESORT_ALLOWBOUNDED, tuplesort_begin_heap(), tuplesort_gettupleslot(), TUPLESORT_NONE, tuplesort_performsort(), tuplesort_puttupleslot(), tuplesort_reset(), tuplesort_set_bound(), and work_mem.
Referenced by ExecIncrementalSort().