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