mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Assorted preparatory refactoring for partition-wise join.
Instead of duplicating the logic to search for a matching ParamPathInfo in multiple places, factor it out into a separate function. Pass only the relevant bits of the PartitionKey to partition_bounds_equal instead of the whole thing, because partition-wise join will want to call this without having a PartitionKey available. Adjust allow_star_schema_join and calc_nestloop_required_outer to take relevant Relids rather than the entire Path, because partition-wise join will want to call it with the top-parent relids to determine whether a child join is allowable. Ashutosh Bapat. Review and testing of the larger patch set of which this is a part by Amit Langote, Rajkumar Raghuwanshi, Rafia Sabih, Thomas Munro, Dilip Kumar, and me. Discussion: http://postgr.es/m/CA+TgmobQK80vtXjAsPZWWXd7c8u13G86gmuLupN+uUJjA+i4nA@mail.gmail.com
This commit is contained in:
@ -1048,12 +1048,8 @@ get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel,
|
||||
Assert(!bms_overlap(baserel->relids, required_outer));
|
||||
|
||||
/* If we already have a PPI for this parameterization, just return it */
|
||||
foreach(lc, baserel->ppilist)
|
||||
{
|
||||
ppi = (ParamPathInfo *) lfirst(lc);
|
||||
if (bms_equal(ppi->ppi_req_outer, required_outer))
|
||||
return ppi;
|
||||
}
|
||||
if ((ppi = find_param_path_info(baserel, required_outer)))
|
||||
return ppi;
|
||||
|
||||
/*
|
||||
* Identify all joinclauses that are movable to this base rel given this
|
||||
@ -1290,12 +1286,8 @@ get_joinrel_parampathinfo(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
*restrict_clauses = list_concat(pclauses, *restrict_clauses);
|
||||
|
||||
/* If we already have a PPI for this parameterization, just return it */
|
||||
foreach(lc, joinrel->ppilist)
|
||||
{
|
||||
ppi = (ParamPathInfo *) lfirst(lc);
|
||||
if (bms_equal(ppi->ppi_req_outer, required_outer))
|
||||
return ppi;
|
||||
}
|
||||
if ((ppi = find_param_path_info(joinrel, required_outer)))
|
||||
return ppi;
|
||||
|
||||
/* Estimate the number of rows returned by the parameterized join */
|
||||
rows = get_parameterized_joinrel_size(root, joinrel,
|
||||
@ -1334,7 +1326,6 @@ ParamPathInfo *
|
||||
get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
|
||||
{
|
||||
ParamPathInfo *ppi;
|
||||
ListCell *lc;
|
||||
|
||||
/* Unparameterized paths have no ParamPathInfo */
|
||||
if (bms_is_empty(required_outer))
|
||||
@ -1343,12 +1334,8 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
|
||||
Assert(!bms_overlap(appendrel->relids, required_outer));
|
||||
|
||||
/* If we already have a PPI for this parameterization, just return it */
|
||||
foreach(lc, appendrel->ppilist)
|
||||
{
|
||||
ppi = (ParamPathInfo *) lfirst(lc);
|
||||
if (bms_equal(ppi->ppi_req_outer, required_outer))
|
||||
return ppi;
|
||||
}
|
||||
if ((ppi = find_param_path_info(appendrel, required_outer)))
|
||||
return ppi;
|
||||
|
||||
/* Else build the ParamPathInfo */
|
||||
ppi = makeNode(ParamPathInfo);
|
||||
@ -1359,3 +1346,23 @@ get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
|
||||
|
||||
return ppi;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a ParamPathInfo for the parameterization given by required_outer, if
|
||||
* already available in the given rel. Returns NULL otherwise.
|
||||
*/
|
||||
ParamPathInfo *
|
||||
find_param_path_info(RelOptInfo *rel, Relids required_outer)
|
||||
{
|
||||
ListCell *lc;
|
||||
|
||||
foreach(lc, rel->ppilist)
|
||||
{
|
||||
ParamPathInfo *ppi = (ParamPathInfo *) lfirst(lc);
|
||||
|
||||
if (bms_equal(ppi->ppi_req_outer, required_outer))
|
||||
return ppi;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user