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
24
typedef
struct
pgpa_plan_walker_context
pgpa_plan_walker_context
;
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
*/
55
typedef
enum
56
{
57
PGPA_SCAN_ORDINARY
= 0,
58
PGPA_SCAN_SEQ
,
59
PGPA_SCAN_BITMAP_HEAP
,
60
PGPA_SCAN_FOREIGN
,
61
PGPA_SCAN_INDEX
,
62
PGPA_SCAN_INDEX_ONLY
,
63
PGPA_SCAN_PARTITIONWISE
,
64
PGPA_SCAN_TID
65
/* update NUM_PGPA_SCAN_STRATEGY if you add anything here */
66
}
pgpa_scan_strategy
;
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
*/
73
typedef
struct
pgpa_scan
74
{
75
Plan
*
plan
;
76
pgpa_scan_strategy
strategy
;
77
Bitmapset
*
relids
;
78
}
pgpa_scan
;
79
80
extern
pgpa_scan
*
pgpa_build_scan
(
pgpa_plan_walker_context
*
walker
,
Plan
*
plan
,
81
ElidedNode
*elided_node,
82
bool
beneath_any_gather
,
83
bool
within_join_problem
);
84
85
#endif
plan
#define plan(x)
Definition
pg_regress.c:161
pgpa_scan_strategy
pgpa_scan_strategy
Definition
pgpa_scan.h:56
PGPA_SCAN_SEQ
@ PGPA_SCAN_SEQ
Definition
pgpa_scan.h:58
PGPA_SCAN_INDEX
@ PGPA_SCAN_INDEX
Definition
pgpa_scan.h:61
PGPA_SCAN_INDEX_ONLY
@ PGPA_SCAN_INDEX_ONLY
Definition
pgpa_scan.h:62
PGPA_SCAN_BITMAP_HEAP
@ PGPA_SCAN_BITMAP_HEAP
Definition
pgpa_scan.h:59
PGPA_SCAN_FOREIGN
@ PGPA_SCAN_FOREIGN
Definition
pgpa_scan.h:60
PGPA_SCAN_TID
@ PGPA_SCAN_TID
Definition
pgpa_scan.h:64
PGPA_SCAN_PARTITIONWISE
@ PGPA_SCAN_PARTITIONWISE
Definition
pgpa_scan.h:63
PGPA_SCAN_ORDINARY
@ PGPA_SCAN_ORDINARY
Definition
pgpa_scan.h:57
pgpa_build_scan
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
plannodes.h
fb
static int fb(int x)
Definition
preproc-init.c:92
Bitmapset
Definition
bitmapset.h:50
ElidedNode
Definition
plannodes.h:1867
Plan
Definition
plannodes.h:192
pgpa_plan_walker_context
Definition
pgpa_walker.h:113
pgpa_scan
Definition
pgpa_scan.h:74
pgpa_scan::plan
Plan * plan
Definition
pgpa_scan.h:75
pgpa_scan::strategy
pgpa_scan_strategy strategy
Definition
pgpa_scan.h:76
pgpa_scan::relids
Bitmapset * relids
Definition
pgpa_scan.h:77
contrib
pg_plan_advice
pgpa_scan.h
Generated on Fri Mar 13 2026 12:13:10 for PostgreSQL Source Code by
1.9.8