mirror of
https://github.com/postgres/postgres.git
synced 2025-10-28 11:55:03 +03:00
Change more places to be less trusting of RestrictInfo.is_pushed_down.
On further reflection, commit e5d83995e didn't go far enough: pretty much
everywhere in the planner that examines a clause's is_pushed_down flag
ought to be changed to use the more complicated behavior where we also
check the clause's required_relids. Otherwise we could make incorrect
decisions about whether, say, a clause is safe to use as a hash clause.
Some (many?) of these places are safe as-is, either because they are
never reached while considering a parameterized path, or because there
are additional checks that would reject a pushed-down clause anyway.
However, it seems smarter to just code them all the same way rather
than rely on easily-broken reasoning of that sort.
In support of that, invent a new macro RINFO_IS_PUSHED_DOWN that should
be used in place of direct tests on the is_pushed_down flag.
Like the previous patch, back-patch to all supported branches.
Discussion: https://postgr.es/m/f8128b11-c5bf-3539-48cd-234178b2314d@proxel.se
This commit is contained in:
@@ -159,6 +159,7 @@ static bool has_indexed_join_quals(NestPath *joinpath);
|
||||
static double approx_tuple_count(PlannerInfo *root, JoinPath *path,
|
||||
List *quals);
|
||||
static double calc_joinrel_size_estimate(PlannerInfo *root,
|
||||
RelOptInfo *joinrel,
|
||||
RelOptInfo *outer_rel,
|
||||
RelOptInfo *inner_rel,
|
||||
double outer_rows,
|
||||
@@ -4055,12 +4056,14 @@ compute_semi_anti_join_factors(PlannerInfo *root,
|
||||
*/
|
||||
if (IS_OUTER_JOIN(jointype))
|
||||
{
|
||||
Relids joinrelids = bms_union(outerrel->relids, innerrel->relids);
|
||||
|
||||
joinquals = NIL;
|
||||
foreach(l, restrictlist)
|
||||
{
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (!rinfo->is_pushed_down)
|
||||
if (!RINFO_IS_PUSHED_DOWN(rinfo, joinrelids))
|
||||
joinquals = lappend(joinquals, rinfo);
|
||||
}
|
||||
}
|
||||
@@ -4375,6 +4378,7 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *restrictlist)
|
||||
{
|
||||
rel->rows = calc_joinrel_size_estimate(root,
|
||||
rel,
|
||||
outer_rel,
|
||||
inner_rel,
|
||||
outer_rel->rows,
|
||||
@@ -4417,6 +4421,7 @@ get_parameterized_joinrel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
* estimate for any pair with the same parameterization.
|
||||
*/
|
||||
nrows = calc_joinrel_size_estimate(root,
|
||||
rel,
|
||||
outer_path->parent,
|
||||
inner_path->parent,
|
||||
outer_path->rows,
|
||||
@@ -4440,6 +4445,7 @@ get_parameterized_joinrel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
*/
|
||||
static double
|
||||
calc_joinrel_size_estimate(PlannerInfo *root,
|
||||
RelOptInfo *joinrel,
|
||||
RelOptInfo *outer_rel,
|
||||
RelOptInfo *inner_rel,
|
||||
double outer_rows,
|
||||
@@ -4492,7 +4498,7 @@ calc_joinrel_size_estimate(PlannerInfo *root,
|
||||
{
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (rinfo->is_pushed_down)
|
||||
if (RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
|
||||
pushedquals = lappend(pushedquals, rinfo);
|
||||
else
|
||||
joinquals = lappend(joinquals, rinfo);
|
||||
|
||||
Reference in New Issue
Block a user