aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util/restrictinfo.c
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2024-11-24 01:41:45 +0200
committerAlexander Korotkov <akorotkov@postgresql.org>2024-11-24 01:41:45 +0200
commitae4569161a27823793ca24825bbabce2a91a0bc9 (patch)
tree59d2131807aed4b471ad48e0d7a0e55bfa213ff9 /src/backend/optimizer/util/restrictinfo.c
parentd4378c0005e61b1bb78e88097ea6efcdddbe2d6e (diff)
downloadpostgresql-ae4569161a27823793ca24825bbabce2a91a0bc9.tar.gz
postgresql-ae4569161a27823793ca24825bbabce2a91a0bc9.zip
Teach bitmap path generation about transforming OR-clauses to SAOP's
When optimizer generates bitmap paths, it considers breaking OR-clause arguments one-by-one. But now, a group of similar OR-clauses can be transformed into SAOP during index matching. So, bitmap paths should keep up. This commit teaches bitmap paths generation machinery to group similar OR-clauses into dedicated RestrictInfos. Those RestrictInfos are considered both to match index as a whole (as SAOP), or to match as a set of individual OR-clause argument one-by-one (the old way). Therefore, bitmap path generation will takes advantage of OR-clauses to SAOP's transformation. The old way of handling them is also considered. So, there shouldn't be planning regression. Discussion: https://postgr.es/m/CAPpHfdu5iQOjF93vGbjidsQkhHvY2NSm29duENYH_cbhC6x%2BMg%40mail.gmail.com Author: Alexander Korotkov, Andrey Lepikhov Reviewed-by: Alena Rybakina, Andrei Lepikhov, Jian he, Robert Haas Reviewed-by: Peter Geoghegan
Diffstat (limited to 'src/backend/optimizer/util/restrictinfo.c')
-rw-r--r--src/backend/optimizer/util/restrictinfo.c107
1 files changed, 49 insertions, 58 deletions
diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c
index 0b406e93342..9e1458401c2 100644
--- a/src/backend/optimizer/util/restrictinfo.c
+++ b/src/backend/optimizer/util/restrictinfo.c
@@ -21,17 +21,6 @@
#include "optimizer/restrictinfo.h"
-static RestrictInfo *make_restrictinfo_internal(PlannerInfo *root,
- Expr *clause,
- Expr *orclause,
- bool is_pushed_down,
- bool has_clone,
- bool is_clone,
- bool pseudoconstant,
- Index security_level,
- Relids required_relids,
- Relids incompatible_relids,
- Relids outer_relids);
static Expr *make_sub_restrictinfos(PlannerInfo *root,
Expr *clause,
bool is_pushed_down,
@@ -90,36 +79,38 @@ make_restrictinfo(PlannerInfo *root,
/* Shouldn't be an AND clause, else AND/OR flattening messed up */
Assert(!is_andclause(clause));
- return make_restrictinfo_internal(root,
- clause,
- NULL,
- is_pushed_down,
- has_clone,
- is_clone,
- pseudoconstant,
- security_level,
- required_relids,
- incompatible_relids,
- outer_relids);
+ return make_plain_restrictinfo(root,
+ clause,
+ NULL,
+ is_pushed_down,
+ has_clone,
+ is_clone,
+ pseudoconstant,
+ security_level,
+ required_relids,
+ incompatible_relids,
+ outer_relids);
}
/*
- * make_restrictinfo_internal
+ * make_plain_restrictinfo
*
- * Common code for the main entry points and the recursive cases.
+ * Common code for the main entry points and the recursive cases. Also,
+ * useful while contrucitng RestrictInfos above OR clause, which already has
+ * RestrictInfos above its subclauses.
*/
-static RestrictInfo *
-make_restrictinfo_internal(PlannerInfo *root,
- Expr *clause,
- Expr *orclause,
- bool is_pushed_down,
- bool has_clone,
- bool is_clone,
- bool pseudoconstant,
- Index security_level,
- Relids required_relids,
- Relids incompatible_relids,
- Relids outer_relids)
+RestrictInfo *
+make_plain_restrictinfo(PlannerInfo *root,
+ Expr *clause,
+ Expr *orclause,
+ bool is_pushed_down,
+ bool has_clone,
+ bool is_clone,
+ bool pseudoconstant,
+ Index security_level,
+ Relids required_relids,
+ Relids incompatible_relids,
+ Relids outer_relids)
{
RestrictInfo *restrictinfo = makeNode(RestrictInfo);
Relids baserels;
@@ -296,17 +287,17 @@ make_sub_restrictinfos(PlannerInfo *root,
NULL,
incompatible_relids,
outer_relids));
- return (Expr *) make_restrictinfo_internal(root,
- clause,
- make_orclause(orlist),
- is_pushed_down,
- has_clone,
- is_clone,
- pseudoconstant,
- security_level,
- required_relids,
- incompatible_relids,
- outer_relids);
+ return (Expr *) make_plain_restrictinfo(root,
+ clause,
+ make_orclause(orlist),
+ is_pushed_down,
+ has_clone,
+ is_clone,
+ pseudoconstant,
+ security_level,
+ required_relids,
+ incompatible_relids,
+ outer_relids);
}
else if (is_andclause(clause))
{
@@ -328,17 +319,17 @@ make_sub_restrictinfos(PlannerInfo *root,
return make_andclause(andlist);
}
else
- return (Expr *) make_restrictinfo_internal(root,
- clause,
- NULL,
- is_pushed_down,
- has_clone,
- is_clone,
- pseudoconstant,
- security_level,
- required_relids,
- incompatible_relids,
- outer_relids);
+ return (Expr *) make_plain_restrictinfo(root,
+ clause,
+ NULL,
+ is_pushed_down,
+ has_clone,
+ is_clone,
+ pseudoconstant,
+ security_level,
+ required_relids,
+ incompatible_relids,
+ outer_relids);
}
/*