提交 f31bf88a 编写于 作者: D Daniel Gustafsson

Cosmetic cleanups around join ordering code

Fixing some of the more obvious breaches of common style around
the code I just read for another patchset. There is no logical
changes introduced here, only rearrangement for clarity.

Discussion: https://github.com/greenplum-db/gpdb/pull/5216Reviewed-by: NVenkatesh Raghavan <vraghavan@pivotal.io>
上级 281f0f88
...@@ -118,8 +118,7 @@ make_one_rel(PlannerInfo *root, List *joinlist) ...@@ -118,8 +118,7 @@ make_one_rel(PlannerInfo *root, List *joinlist)
rel = make_rel_from_joinlist(root, joinlist); rel = make_rel_from_joinlist(root, joinlist);
/* CDB: No path might be found if user set enable_xxx = off */ /* CDB: No path might be found if user set enable_xxx = off */
if (!rel || if (!rel || !rel->cheapest_total_path)
!rel->cheapest_total_path)
cdb_no_path_for_query(); /* raise error - no return */ cdb_no_path_for_query(); /* raise error - no return */
/* /*
...@@ -1335,8 +1334,7 @@ make_rel_from_joinlist(PlannerInfo *root, List *joinlist) ...@@ -1335,8 +1334,7 @@ make_rel_from_joinlist(PlannerInfo *root, List *joinlist)
} }
/* CDB: Fail if no path could be built due to set enable_xxx = off. */ /* CDB: Fail if no path could be built due to set enable_xxx = off. */
if (!thisrel || if (!thisrel || !thisrel->cheapest_total_path)
!thisrel->cheapest_total_path)
return NULL; return NULL;
initial_rels = lappend(initial_rels, thisrel); initial_rels = lappend(initial_rels, thisrel);
...@@ -1456,9 +1454,7 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels, b ...@@ -1456,9 +1454,7 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels, b
* Do cleanup work on each just-processed rel. * Do cleanup work on each just-processed rel.
*/ */
prev = NULL; prev = NULL;
for (lc = list_head(root->join_rel_level[lev]); for (lc = list_head(root->join_rel_level[lev]); lc != NULL; lc = next)
lc != NULL;
lc = next)
{ {
next = lnext(lc); next = lnext(lc);
rel = (RelOptInfo *) lfirst(lc); rel = (RelOptInfo *) lfirst(lc);
......
...@@ -442,66 +442,68 @@ cdb_estimate_rel_size(RelOptInfo *relOptInfo, ...@@ -442,66 +442,68 @@ cdb_estimate_rel_size(RelOptInfo *relOptInfo,
return; return;
} }
/* coerce values in pg_class to more desirable types */ /* coerce values in pg_class to more desirable types */
relpages = (BlockNumber) rel->rd_rel->relpages; relpages = (BlockNumber) rel->rd_rel->relpages;
reltuples = (double) rel->rd_rel->reltuples; reltuples = (double) rel->rd_rel->reltuples;
/* /*
* Asking the QE for the size of the relation is a bit expensive. * Asking the QE for the size of the relation is a bit expensive. Do we
* Do we want to do it all the time? Or only for tables that have never had analyze run? * want to do it all the time? Or only for tables that have never had
* analyze run?
*/ */
if (relpages > 0) if (relpages > 0)
{ {
/* /*
* Let's trust the values we had from analyze, even though they might be out of date. * Let's trust the values we had from analyze, even though they might
* be out of date.
* *
* NOTE: external tables are created with estimated larger than zero values. therefore * NOTE: external tables are created with estimated larger than zero
* we will get here too even though we can never analyze them. * values, therefore we will get here too even though we can never
* analyze them.
*/ */
curpages = relpages; curpages = relpages;
} }
else if (RelationIsExternal(rel)) else if (RelationIsExternal(rel))
{ {
/*
* If the relation is an external table use default curpages
*/
curpages = DEFAULT_EXTERNAL_TABLE_PAGES; curpages = DEFAULT_EXTERNAL_TABLE_PAGES;
} }
else else
{ {
/* /*
* If GUC gp_enable_relsize_collection is on, get the size of the table to derive curpages * If GUC gp_enable_relsize_collection is on, get the size of the table
* else use the default value * to derive curpages, else use the default value.
*/ */
curpages = gp_enable_relsize_collection ? cdbRelMaxSegSize(rel) / BLCKSZ : DEFAULT_INTERNAL_TABLE_PAGES; if (gp_enable_relsize_collection)
curpages = cdbRelMaxSegSize(rel) / BLCKSZ;
else
curpages = DEFAULT_INTERNAL_TABLE_PAGES;
} }
/* report estimated # pages */ /* report estimated # pages */
*pages = curpages; *pages = curpages;
/* /*
* If it's an index, discount the metapage. This is a kluge * If it's an index, discount the metapage. This is a kluge because it
* because it assumes more than it ought to about index contents; * assumes more than it ought to about index contents; it's reasonably OK
* it's reasonably OK for btrees but a bit suspect otherwise. * for btrees but a bit suspect otherwise.
*/ */
if (rel->rd_rel->relkind == RELKIND_INDEX && if (rel->rd_rel->relkind == RELKIND_INDEX && relpages > 0)
relpages > 0)
{ {
curpages--; curpages--;
relpages--; relpages--;
} }
/* estimate number of tuples from previous tuple density (as of last analyze) */
/*
* Estimate number of tuples from previous tuple density (as of last
* analyze)
*/
if (relpages > 0) if (relpages > 0)
density = reltuples / (double) relpages; density = reltuples / (double) relpages;
else else
{ {
/* /*
* When we have no data because the relation was truncated, * When we have no data because the relation was truncated, estimate
* estimate tuples per page from attribute datatypes. * tuples per page from attribute datatypes.
* *
* (This is the same computation as in get_relation_info() * (This is the same computation as in get_relation_info()
*/ */
...@@ -515,9 +517,9 @@ cdb_estimate_rel_size(RelOptInfo *relOptInfo, ...@@ -515,9 +517,9 @@ cdb_estimate_rel_size(RelOptInfo *relOptInfo,
} }
*tuples = ceil(density * curpages); *tuples = ceil(density * curpages);
elog(DEBUG2,"cdb_estimate_rel_size estimated %g tuples and %d pages",*tuples,(int)*pages); elog(DEBUG2, "cdb_estimate_rel_size estimated %g tuples and %d pages",
*tuples, (int) *pages);
} /* cdb_estimate_rel_size */ }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册