PostgreSQL Source Code
git master
Loading...
Searching...
No Matches
pgpa_trove.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* pgpa_trove.h
4
* All of the advice given for a particular query, appropriately
5
* organized for convenient access.
6
*
7
* Copyright (c) 2016-2026, PostgreSQL Global Development Group
8
*
9
* contrib/pg_plan_advice/pgpa_trove.h
10
*
11
*-------------------------------------------------------------------------
12
*/
13
#ifndef PGPA_TROVE_H
14
#define PGPA_TROVE_H
15
16
#include "
pgpa_ast.h
"
17
18
#include "
nodes/bitmapset.h
"
19
20
typedef
struct
pgpa_trove
pgpa_trove
;
21
22
/*
23
* Flags that can be set on a pgpa_trove_entry to indicate what happened when
24
* trying to plan using advice.
25
*
26
* PGPA_TE_MATCH_PARTIAL means that we found some part of the query that at
27
* least partially matched the target; e.g. given JOIN_ORDER(a b), this would
28
* be set if we ever saw any joinrel including either "a" or "b".
29
*
30
* PGPA_TE_MATCH_FULL means that we found an exact match for the target; e.g.
31
* given JOIN_ORDER(a b), this would be set if we saw a joinrel containing
32
* exactly "a" and "b" and nothing else.
33
*
34
* PGPA_TE_INAPPLICABLE means that the advice doesn't properly apply to the
35
* target; e.g. INDEX_SCAN(foo bar_idx) would be so marked if bar_idx does not
36
* exist on foo. The fact that this bit has been set does not mean that the
37
* advice had no effect.
38
*
39
* PGPA_TE_CONFLICTING means that a conflict was detected between what this
40
* advice wants and what some other plan advice wants; e.g. JOIN_ORDER(a b)
41
* would conflict with HASH_JOIN(a), because the former requires "a" to be the
42
* outer table while the latter requires it to be the inner table.
43
*
44
* PGPA_TE_FAILED means that the resulting plan did not conform to the advice.
45
*/
46
#define PGPA_TE_MATCH_PARTIAL 0x0001
47
#define PGPA_TE_MATCH_FULL 0x0002
48
#define PGPA_TE_INAPPLICABLE 0x0004
49
#define PGPA_TE_CONFLICTING 0x0008
50
#define PGPA_TE_FAILED 0x0010
51
52
/*
53
* Each entry in a trove of advice represents the application of a tag to
54
* a single target.
55
*/
56
typedef
struct
pgpa_trove_entry
57
{
58
pgpa_advice_tag_type
tag
;
59
pgpa_advice_target
*
target
;
60
int
flags
;
61
}
pgpa_trove_entry
;
62
63
/*
64
* What kind of information does the caller want to find in a trove?
65
*
66
* PGPA_TROVE_LOOKUP_SCAN means we're looking for scan advice.
67
*
68
* PGPA_TROVE_LOOKUP_JOIN means we're looking for join-related advice.
69
* This includes join order advice, join method advice, and semijoin-uniqueness
70
* advice.
71
*
72
* PGPA_TROVE_LOOKUP_REL means we're looking for general advice about this
73
* a RelOptInfo that may correspond to either a scan or a join. This includes
74
* gather-related advice and partitionwise advice. Note that partitionwise
75
* advice might seem like join advice, but that's not a helpful way of viewing
76
* the matter because (1) partitionwise advice is also relevant at the scan
77
* level and (2) other types of join advice affect only what to do from
78
* join_path_setup_hook, but partitionwise advice affects what to do in
79
* joinrel_setup_hook.
80
*/
81
typedef
enum
pgpa_trove_lookup_type
82
{
83
PGPA_TROVE_LOOKUP_JOIN
,
84
PGPA_TROVE_LOOKUP_REL
,
85
PGPA_TROVE_LOOKUP_SCAN
86
}
pgpa_trove_lookup_type
;
87
88
/*
89
* This struct is used to store the result of a trove lookup. For each member
90
* of "indexes", the entry at the corresponding offset within "entries" is one
91
* of the results.
92
*/
93
typedef
struct
pgpa_trove_result
94
{
95
pgpa_trove_entry
*
entries
;
96
Bitmapset
*
indexes
;
97
}
pgpa_trove_result
;
98
99
extern
pgpa_trove
*
pgpa_build_trove
(
List
*
advice_items
);
100
extern
void
pgpa_trove_lookup
(
pgpa_trove
*trove,
101
pgpa_trove_lookup_type
type
,
102
int
nrids
,
103
pgpa_identifier
*rids,
104
pgpa_trove_result
*result);
105
extern
void
pgpa_trove_lookup_all
(
pgpa_trove
*trove,
106
pgpa_trove_lookup_type
type
,
107
pgpa_trove_entry
**entries,
108
int
*nentries);
109
extern
char
*
pgpa_cstring_trove_entry
(
pgpa_trove_entry
*entry);
110
extern
void
pgpa_trove_set_flags
(
pgpa_trove_entry
*entries,
111
Bitmapset
*indexes,
int
flags);
112
extern
void
pgpa_trove_append_flags
(
StringInfo
buf
,
int
flags);
113
114
#endif
bitmapset.h
buf
static char buf[DEFAULT_XLOG_SEG_SIZE]
Definition
pg_test_fsync.c:71
pgpa_ast.h
pgpa_advice_tag_type
pgpa_advice_tag_type
Definition
pgpa_ast.h:81
pgpa_trove_set_flags
void pgpa_trove_set_flags(pgpa_trove_entry *entries, Bitmapset *indexes, int flags)
Definition
pgpa_trove.c:326
pgpa_trove_lookup_type
pgpa_trove_lookup_type
Definition
pgpa_trove.h:82
PGPA_TROVE_LOOKUP_SCAN
@ PGPA_TROVE_LOOKUP_SCAN
Definition
pgpa_trove.h:85
PGPA_TROVE_LOOKUP_JOIN
@ PGPA_TROVE_LOOKUP_JOIN
Definition
pgpa_trove.h:83
PGPA_TROVE_LOOKUP_REL
@ PGPA_TROVE_LOOKUP_REL
Definition
pgpa_trove.h:84
pgpa_build_trove
pgpa_trove * pgpa_build_trove(List *advice_items)
Definition
pgpa_trove.c:132
pgpa_trove_append_flags
void pgpa_trove_append_flags(StringInfo buf, int flags)
Definition
pgpa_trove.c:343
pgpa_trove_lookup_all
void pgpa_trove_lookup_all(pgpa_trove *trove, pgpa_trove_lookup_type type, pgpa_trove_entry **entries, int *nentries)
Definition
pgpa_trove.c:275
pgpa_cstring_trove_entry
char * pgpa_cstring_trove_entry(pgpa_trove_entry *entry)
Definition
pgpa_trove.c:295
pgpa_trove_lookup
void pgpa_trove_lookup(pgpa_trove *trove, pgpa_trove_lookup_type type, int nrids, pgpa_identifier *rids, pgpa_trove_result *result)
Definition
pgpa_trove.c:233
fb
static int fb(int x)
Definition
preproc-init.c:92
Bitmapset
Definition
bitmapset.h:50
List
Definition
pg_list.h:54
StringInfoData
Definition
stringinfo.h:47
pgpa_advice_target
Definition
pgpa_ast.h:48
pgpa_identifier
Definition
pgpa_identifier.h:20
pgpa_trove_entry
Definition
pgpa_trove.h:57
pgpa_trove_entry::target
pgpa_advice_target * target
Definition
pgpa_trove.h:59
pgpa_trove_entry::tag
pgpa_advice_tag_type tag
Definition
pgpa_trove.h:58
pgpa_trove_entry::flags
int flags
Definition
pgpa_trove.h:60
pgpa_trove_result
Definition
pgpa_trove.h:94
pgpa_trove_result::entries
pgpa_trove_entry * entries
Definition
pgpa_trove.h:95
pgpa_trove_result::indexes
Bitmapset * indexes
Definition
pgpa_trove.h:96
pgpa_trove
Definition
pgpa_trove.c:51
type
const char * type
Definition
wait_event_funcs.c:27
contrib
pg_plan_advice
pgpa_trove.h
Generated on Fri Mar 13 2026 12:13:10 for PostgreSQL Source Code by
1.9.8