PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pgpa_scan.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pgpa_scan.h
4 * analysis of scans in Plan trees
5 *
6 * For purposes of this module, a "scan" includes (1) single plan nodes that
7 * scan multiple RTIs, such as a degenerate Result node that replaces what
8 * would otherwise have been a join, and (2) Append and MergeAppend nodes
9 * implementing a partitionwise scan or a partitionwise join. Said
10 * differently, scans are the leaves of the join tree for a single join
11 * problem.
12 *
13 * Copyright (c) 2016-2026, PostgreSQL Global Development Group
14 *
15 * contrib/pg_plan_advice/pgpa_scan.h
16 *
17 *-------------------------------------------------------------------------
18 */
19#ifndef PGPA_SCAN_H
20#define PGPA_SCAN_H
21
22#include "nodes/plannodes.h"
23
25
26/*
27 * Scan strategies.
28 *
29 * PGPA_SCAN_ORDINARY is any scan strategy that isn't interesting to us
30 * because there is no meaningful planner decision involved. For example,
31 * the only way to scan a subquery is a SubqueryScan, and the only way to
32 * scan a VALUES construct is a ValuesScan. We need not care exactly which
33 * type of planner node was used in such cases, because the same thing will
34 * happen when replanning.
35 *
36 * PGPA_SCAN_ORDINARY also includes Result nodes that correspond to scans
37 * or even joins that are proved empty. We don't know whether or not the scan
38 * or join will still be provably empty at replanning time, but if it is,
39 * then no scan-type advice is needed, and if it's not, we can't recommend
40 * a scan type based on the current plan.
41 *
42 * PGPA_SCAN_PARTITIONWISE also lumps together scans and joins: this can
43 * be either a partitionwise scan of a partitioned table or a partitionwise
44 * join between several partitioned tables. Note that all decisions about
45 * whether or not to use partitionwise join are meaningful: no matter what
46 * we decided this time, we could do more or fewer things partitionwise the
47 * next time.
48 *
49 * PGPA_SCAN_FOREIGN is only used when there's more than one relation involved;
50 * a single-table foreign scan is classified as ordinary, since there is no
51 * decision to make in that case.
52 *
53 * Other scan strategies map one-to-one to plan nodes.
54 */
67
68#define NUM_PGPA_SCAN_STRATEGY ((int) PGPA_SCAN_TID + 1)
69
70/*
71 * All of the details we need regarding a scan.
72 */
79
81 ElidedNode *elided_node,
84
85#endif
#define plan(x)
Definition pg_regress.c:161
pgpa_scan_strategy
Definition pgpa_scan.h:56
@ PGPA_SCAN_SEQ
Definition pgpa_scan.h:58
@ PGPA_SCAN_INDEX
Definition pgpa_scan.h:61
@ PGPA_SCAN_INDEX_ONLY
Definition pgpa_scan.h:62
@ PGPA_SCAN_BITMAP_HEAP
Definition pgpa_scan.h:59
@ PGPA_SCAN_FOREIGN
Definition pgpa_scan.h:60
@ PGPA_SCAN_TID
Definition pgpa_scan.h:64
@ PGPA_SCAN_PARTITIONWISE
Definition pgpa_scan.h:63
@ PGPA_SCAN_ORDINARY
Definition pgpa_scan.h:57
pgpa_scan * pgpa_build_scan(pgpa_plan_walker_context *walker, Plan *plan, ElidedNode *elided_node, bool beneath_any_gather, bool within_join_problem)
Definition pgpa_scan.c:44
static int fb(int x)
Plan * plan
Definition pgpa_scan.h:75
pgpa_scan_strategy strategy
Definition pgpa_scan.h:76
Bitmapset * relids
Definition pgpa_scan.h:77