Skip to content

Commit d206c01

Browse files
committed
Introduce clauselist_selectivity_hook
1 parent fa25dfc commit d206c01

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include $(top_builddir)/src/Makefile.global
66

77
SUBDIRS = \
88
amcheck \
9+
pg_index_stats \
910
auth_delay \
1011
auto_explain \
1112
basic_archive \

src/backend/optimizer/path/clausesel.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ clauselist_selectivity_ext(PlannerInfo *root,
128128
ListCell *l;
129129
int listidx;
130130

131+
if (clauselist_selectivity_hook)
132+
s1 = clauselist_selectivity_hook(root, clauses, varRelid, jointype,
133+
sjinfo, &estimatedclauses,
134+
use_extended_stats);
135+
131136
/*
132137
* If there's exactly one clause, just go directly to
133138
* clause_selectivity_ext(). None of what we might do below is relevant.

src/backend/statistics/extended_stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ statext_is_compatible_clause(PlannerInfo *root, Node *clause, Index relid,
17121712
* 0-based 'clauses' indexes we estimate for and also skip clause items that
17131713
* already have a bit set.
17141714
*/
1715-
static Selectivity
1715+
Selectivity
17161716
statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid,
17171717
JoinType jointype, SpecialJoinInfo *sjinfo,
17181718
RelOptInfo *rel, Bitmapset **estimatedclauses,

src/backend/utils/adt/selfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
/* Hooks for plugins to get control when we ask for stats */
147147
get_relation_stats_hook_type get_relation_stats_hook = NULL;
148148
get_index_stats_hook_type get_index_stats_hook = NULL;
149+
clauselist_selectivity_hook_type clauselist_selectivity_hook = NULL;
149150

150151
static double eqsel_internal(PG_FUNCTION_ARGS, bool negate);
151152
static double eqjoinsel_inner(Oid opfuncoid, Oid collation,

src/include/statistics/statistics.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ extern void BuildRelationExtStatistics(Relation onerel, bool inh, double totalro
104104
extern int ComputeExtStatisticsRows(Relation onerel,
105105
int natts, VacAttrStats **vacattrstats);
106106
extern bool statext_is_kind_built(HeapTuple htup, char type);
107+
extern Selectivity statext_mcv_clauselist_selectivity(PlannerInfo *root,
108+
List *clauses,
109+
int varRelid,
110+
JoinType jointype,
111+
SpecialJoinInfo *sjinfo,
112+
RelOptInfo *rel,
113+
Bitmapset **estimatedclauses,
114+
bool is_or);
107115
extern Selectivity dependencies_clauselist_selectivity(PlannerInfo *root,
108116
List *clauses,
109117
int varRelid,

src/include/utils/selfuncs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
148148
VariableStatData *vardata);
149149
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
150150

151+
/* Hooks for plugins to get control when we ask for selectivity estimation */
152+
typedef Selectivity (*clauselist_selectivity_hook_type) (
153+
PlannerInfo *root,
154+
List *clauses,
155+
int varRelid,
156+
JoinType jointype,
157+
SpecialJoinInfo *sjinfo,
158+
Bitmapset **estimatedclauses,
159+
bool use_extended_stats);
160+
extern PGDLLIMPORT clauselist_selectivity_hook_type clauselist_selectivity_hook;
161+
151162
/* Functions in selfuncs.c */
152163

153164
extern void examine_variable(PlannerInfo *root, Node *node, int varRelid,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy