|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/htup_details.h"#include "common/hashfn.h"#include "executor/executor.h"#include "executor/nodeMemoize.h"#include "lib/ilist.h"#include "miscadmin.h"#include "utils/datum.h"#include "utils/lsyscache.h"#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
| struct | MemoizeTuple |
| struct | MemoizeKey |
| struct | MemoizeEntry |
Macros | |
| #define | MEMO_CACHE_LOOKUP 1 /* Attempt to perform a cache lookup */ |
| #define | MEMO_CACHE_FETCH_NEXT_TUPLE 2 /* Get another tuple from the cache */ |
| #define | MEMO_FILLING_CACHE 3 /* Read outer node to fill cache */ |
| #define | MEMO_CACHE_BYPASS_MODE |
| #define | MEMO_END_OF_SCAN 5 /* Ready for rescan */ |
| #define | EMPTY_ENTRY_MEMORY_BYTES(e) |
| #define | CACHE_TUPLE_BYTES(t) |
| #define | SH_PREFIX memoize |
| #define | SH_ELEMENT_TYPE MemoizeEntry |
| #define | SH_KEY_TYPE MemoizeKey * |
| #define | SH_SCOPE static inline |
| #define | SH_DECLARE |
| #define | SH_PREFIX memoize |
| #define | SH_ELEMENT_TYPE MemoizeEntry |
| #define | SH_KEY_TYPE MemoizeKey * |
| #define | SH_KEY key |
| #define | SH_HASH_KEY(tb, key) MemoizeHash_hash(tb, key) |
| #define | SH_EQUAL(tb, a, b) MemoizeHash_equal(tb, a, b) |
| #define | SH_SCOPE static inline |
| #define | SH_STORE_HASH |
| #define | SH_GET_HASH(tb, a) a->hash |
| #define | SH_DEFINE |
Typedefs | |
| typedef struct MemoizeTuple | MemoizeTuple |
| typedef struct MemoizeKey | MemoizeKey |
| typedef struct MemoizeEntry | MemoizeEntry |
| #define CACHE_TUPLE_BYTES | ( | t | ) |
Definition at line 90 of file nodeMemoize.c.
Definition at line 87 of file nodeMemoize.c.
| #define MEMO_CACHE_BYPASS_MODE |
Definition at line 82 of file nodeMemoize.c.
Definition at line 80 of file nodeMemoize.c.
Definition at line 79 of file nodeMemoize.c.
Definition at line 81 of file nodeMemoize.c.
| #define SH_DECLARE |
Definition at line 130 of file nodeMemoize.c.
| #define SH_DEFINE |
Definition at line 148 of file nodeMemoize.c.
| #define SH_ELEMENT_TYPE MemoizeEntry |
Definition at line 127 of file nodeMemoize.c.
| #define SH_ELEMENT_TYPE MemoizeEntry |
Definition at line 127 of file nodeMemoize.c.
Definition at line 144 of file nodeMemoize.c.
| #define SH_HASH_KEY | ( | tb, | |
| key | |||
| ) | MemoizeHash_hash(tb, key) |
Definition at line 143 of file nodeMemoize.c.
| #define SH_KEY key |
Definition at line 142 of file nodeMemoize.c.
| #define SH_KEY_TYPE MemoizeKey * |
Definition at line 128 of file nodeMemoize.c.
| #define SH_KEY_TYPE MemoizeKey * |
Definition at line 128 of file nodeMemoize.c.
Definition at line 126 of file nodeMemoize.c.
Definition at line 126 of file nodeMemoize.c.
Definition at line 129 of file nodeMemoize.c.
Definition at line 129 of file nodeMemoize.c.
| #define SH_STORE_HASH |
Definition at line 146 of file nodeMemoize.c.
|
static |
Definition at line 283 of file nodeMemoize.c.
Referenced by ExecMemoize().
|
static |
Definition at line 528 of file nodeMemoize.c.
References Assert, cache_reduce_memory(), MemoizeEntry::complete, dlist_move_tail(), dlist_push_tail(), EMPTY_ENTRY_MEMORY_BYTES, ExecCopySlotMinimalTuple(), fb(), MemoizeEntry::key, MemoizeKey::lru_node, MemoryContextSwitchTo(), palloc_object, prepare_probe_slot(), MemoizeEntry::status, MemoizeEntry::tuplehead, and unlikely.
Referenced by ExecMemoize().
|
static |
Definition at line 402 of file nodeMemoize.c.
References dlist_init(), fb(), and MemoryContextReset().
Referenced by ExecReScanMemoize().
|
static |
Definition at line 440 of file nodeMemoize.c.
References Assert, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, elog, ERROR, fb(), MemoizeEntry::key, prepare_probe_slot(), remove_cache_entry(), and unlikely.
Referenced by cache_lookup(), and cache_store_tuple().
|
static |
Definition at line 625 of file nodeMemoize.c.
References Assert, cache_reduce_memory(), CACHE_TUPLE_BYTES, ExecCopySlotMinimalTuple(), fb(), MemoizeEntry::key, MemoryContextSwitchTo(), MemoizeTuple::mintuple, MemoizeTuple::next, palloc_object, prepare_probe_slot(), MemoizeEntry::status, and MemoizeEntry::tuplehead.
Referenced by ExecMemoize().
|
inlinestatic |
Definition at line 344 of file nodeMemoize.c.
References CACHE_TUPLE_BYTES, MemoizeEntry::complete, fb(), MemoizeTuple::mintuple, next, MemoizeTuple::next, pfree(), and MemoizeEntry::tuplehead.
Referenced by ExecMemoize(), and remove_cache_entry().
| void ExecEndMemoize | ( | MemoizeState * | node | ) |
Definition at line 1080 of file nodeMemoize.c.
References Assert, CACHE_TUPLE_BYTES, EMPTY_ENTRY_MEMORY_BYTES, ExecEndNode(), fb(), MemoizeState::hashtable, i, IsParallelWorker, MemoizeInstrumentation::mem_peak, MemoizeState::mem_used, MemoryContextDelete(), MemoizeTuple::next, outerPlanState, ParallelWorkerNumber, MemoizeState::shared_info, SharedMemoizeInfo::sinstrument, MemoizeState::stats, MemoizeState::tableContext, and MemoizeEntry::tuplehead.
Referenced by ExecEndNode().
Definition at line 1172 of file nodeMemoize.c.
Referenced by cost_memoize_rescan().
| MemoizeState * ExecInitMemoize | ( | Memoize * | node, |
| EState * | estate, | ||
| int | eflags | ||
| ) |
Definition at line 952 of file nodeMemoize.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, Memoize::binary_mode, CurrentMemoryContext, dlist_init(), elog, ERROR, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecBuildParamSetEqual(), ExecCreateScanSlotFromOuterPlan(), ExecInitExpr(), ExecInitNode(), ExecInitResultTupleSlotTL(), ExecMemoize(), ExecTypeFromExprList(), fb(), fmgr_info(), get_hash_memory_limit(), get_op_hash_functions(), get_opcode(), i, Memoize::keyparamids, list_nth(), makeNode, MakeSingleTupleTableSlot(), MEMO_CACHE_LOOKUP, Memoize::numKeys, outerPlan, outerPlanState, palloc(), Memoize::param_exprs, pfree(), Memoize::singlerow, TTSOpsMinimalTuple, and TTSOpsVirtual.
Referenced by ExecInitNode().
|
static |
Definition at line 697 of file nodeMemoize.c.
References Assert, build_hash_table(), MemoizeInstrumentation::cache_hits, cache_lookup(), MemoizeInstrumentation::cache_misses, MemoizeInstrumentation::cache_overflows, cache_store_tuple(), castNode, CHECK_FOR_INTERRUPTS, MemoizeEntry::complete, elog, MemoizeState::entry, entry_purge_tuples(), ERROR, ExecCopySlot(), ExecProcNode(), ExecStoreMinimalTuple(), fb(), MemoizeState::hashtable, MemoizeState::last_tuple, likely, MEMO_CACHE_BYPASS_MODE, MEMO_CACHE_FETCH_NEXT_TUPLE, MEMO_CACHE_LOOKUP, MEMO_END_OF_SCAN, MEMO_FILLING_CACHE, MemoizeTuple::mintuple, MemoizeState::mstatus, MemoizeTuple::next, outerPlanState, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, ResetExprContext, MemoizeState::singlerow, MemoizeState::ss, MemoizeState::stats, TupIsNull, MemoizeEntry::tuplehead, and unlikely.
Referenced by ExecInitMemoize().
| void ExecMemoizeEstimate | ( | MemoizeState * | node, |
| ParallelContext * | pcxt | ||
| ) |
Definition at line 1190 of file nodeMemoize.c.
References add_size(), ParallelContext::estimator, fb(), PlanState::instrument, mul_size(), ParallelContext::nworkers, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, and MemoizeState::ss.
Referenced by ExecParallelEstimate().
| void ExecMemoizeInitializeDSM | ( | MemoizeState * | node, |
| ParallelContext * | pcxt | ||
| ) |
Definition at line 1211 of file nodeMemoize.c.
References fb(), PlanState::instrument, SharedMemoizeInfo::num_workers, ParallelContext::nworkers, PlanState::plan, Plan::plan_node_id, ScanState::ps, MemoizeState::shared_info, shm_toc_allocate(), shm_toc_insert(), MemoizeState::ss, and ParallelContext::toc.
Referenced by ExecParallelInitializeDSM().
| void ExecMemoizeInitializeWorker | ( | MemoizeState * | node, |
| ParallelWorkerContext * | pwcxt | ||
| ) |
Definition at line 1236 of file nodeMemoize.c.
References fb(), PlanState::plan, Plan::plan_node_id, ScanState::ps, MemoizeState::shared_info, shm_toc_lookup(), and MemoizeState::ss.
Referenced by ExecParallelInitializeWorker().
| void ExecMemoizeRetrieveInstrumentation | ( | MemoizeState * | node | ) |
Definition at line 1249 of file nodeMemoize.c.
References fb(), SharedMemoizeInfo::num_workers, palloc(), and MemoizeState::shared_info.
Referenced by ExecParallelRetrieveInstrumentation().
| void ExecReScanMemoize | ( | MemoizeState * | node | ) |
Definition at line 1140 of file nodeMemoize.c.
References bms_nonempty_difference(), cache_purge_all(), MemoizeState::entry, ExecReScan(), fb(), MemoizeState::keyparamids, MemoizeState::last_tuple, MEMO_CACHE_LOOKUP, MemoizeState::mstatus, outerPlan, and outerPlanState.
Referenced by ExecReScan().
|
static |
Definition at line 221 of file nodeMemoize.c.
References CompactAttribute::attbyval, CompactAttribute::attlen, datum_image_eq(), ExprContext::ecxt_innertuple, ExprContext::ecxt_outertuple, ExprContext::ecxt_per_tuple_memory, ExecQual(), ExecStoreMinimalTuple(), fb(), i, MemoryContextSwitchTo(), slot_getallattrs(), and TupleDescCompactAttr().
|
static |
Definition at line 158 of file nodeMemoize.c.
References CompactAttribute::attbyval, CompactAttribute::attlen, datum_image_hash(), DatumGetUInt32(), ExprContext::ecxt_per_tuple_memory, fb(), FunctionCall1Coll(), i, MemoryContextSwitchTo(), murmurhash32(), pg_rotate_left32(), and TupleDescCompactAttr().
|
inlinestatic |
Definition at line 302 of file nodeMemoize.c.
References ExprContext::ecxt_per_tuple_memory, ExecClearTuple(), ExecEvalExpr(), ExecStoreMinimalTuple(), ExecStoreVirtualTuple(), fb(), i, MemoryContextSwitchTo(), and slot_getallattrs().
Referenced by cache_lookup(), cache_reduce_memory(), and cache_store_tuple().
|
static |
Definition at line 374 of file nodeMemoize.c.
References dlist_delete(), EMPTY_ENTRY_MEMORY_BYTES, entry_purge_tuples(), fb(), MemoizeEntry::key, MemoizeKey::lru_node, and pfree().
Referenced by cache_reduce_memory().