mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user