PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_stash_advice.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_stash_advice.h
4 * main header for pg_stash_advice contrib module
5 *
6 * This module allows plan advice strings (as used and generated by
7 * pg_plan_advice) to be "stashed" in dynamic shared memory and, from
8 * there, automatically be applied to queries as they are planned.
9 * You can create any number of advice stashes, each of which is
10 * identified by a human-readable, ASCII identifier, and each of them is
11 * essentially a query ID -> advice_string mapping.
12 *
13 * Copyright (c) 2016-2026, PostgreSQL Global Development Group
14 *
15 * contrib/pg_stash_advice/pg_stash_advice.h
16 *
17 *-------------------------------------------------------------------------
18 */
19#ifndef PG_STASH_ADVICE_H
20#define PG_STASH_ADVICE_H
21
22#include "lib/dshash.h"
23#include "storage/lwlock.h"
24
25#define PGSA_DUMP_FILE "pg_stash_advice.tsv"
26
27/*
28 * The key that we use to find a particular stash entry.
29 */
35
36/*
37 * A single stash entry.
38 */
44
45/*
46 * The stash itself is just a mapping from a name to a stash ID.
47 */
53
54/*
55 * Top-level shared state object for pg_stash_advice.
56 */
71
72/* For stash ID -> stash name hash table */
79
80/* Declare stash ID -> stash name hash table */
81#define SH_PREFIX pgsa_stash_name_table
82#define SH_ELEMENT_TYPE pgsa_stash_name
83#define SH_KEY_TYPE uint64
84#define SH_SCOPE extern
85#define SH_DECLARE
86#include "lib/simplehash.h"
87
88/* Shared memory pointers */
93
94/* GUC variables */
95extern bool pg_stash_advice_persist;
97
98/* Function prototypes */
99extern void pgsa_attach(void);
100extern void pgsa_check_lockout(void);
101extern void pgsa_check_stash_name(char *stash_name);
102extern void pgsa_clear_advice_string(char *stash_name, int64 queryId);
103extern void pgsa_create_stash(char *stash_name);
104extern void pgsa_drop_stash(char *stash_name);
105extern uint64 pgsa_lookup_stash_id(char *stash_name);
106extern void pgsa_reset_all_stashes(void);
107extern void pgsa_set_advice_string(char *stash_name, int64 queryId,
108 char *advice_string);
109extern void pgsa_start_worker(void);
110
111#endif
int64_t int64
Definition c.h:621
uint64_t uint64
Definition c.h:625
uint32_t uint32
Definition c.h:624
uint64 dsa_pointer
Definition dsa.h:62
dsm_handle dsa_handle
Definition dsa.h:136
dsa_pointer dshash_table_handle
Definition dshash.h:24
#define NAMEDATALEN
bool pg_stash_advice_persist
dshash_table * pgsa_entry_dshash
dshash_table * pgsa_stash_dshash
void pgsa_create_stash(char *stash_name)
void pgsa_drop_stash(char *stash_name)
void pgsa_set_advice_string(char *stash_name, int64 queryId, char *advice_string)
void pgsa_start_worker(void)
void pgsa_reset_all_stashes(void)
dsa_area * pgsa_dsa_area
uint64 pgsa_lookup_stash_id(char *stash_name)
void pgsa_attach(void)
void pgsa_check_stash_name(char *stash_name)
pgsa_shared_state * pgsa_state
int pg_stash_advice_persist_interval
void pgsa_clear_advice_string(char *stash_name, int64 queryId)
void pgsa_check_lockout(void)
static int fb(int x)
int64 queryId
uint64 pgsa_stash_id
pgsa_entry_key key
dsa_pointer advice_string
dshash_table_handle entry_hash
dshash_table_handle stash_hash
pg_atomic_uint64 change_count
pg_atomic_flag stashes_ready
char name[NAMEDATALEN]
uint64 pgsa_stash_id