summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2016-04-30 18:08:00 +0000
committerTom Lane2016-04-30 18:08:00 +0000
commit2a2435e6995133c9d872ef9cb51432f0b678b978 (patch)
tree7796ce5e1f0c612c7b1fd5475774e88b63407b14
parentc45bf5751b6338488bd79ce777210285531da373 (diff)
Small improvements to OPTIMIZER_DEBUG code.
Now that Paths have their own rows field, print that rather than the parent relation's rowcount. Show the relid sets associated with Paths using table names rather than numbers; since this code is able to print simple Var references using table names, it seems a bit silly that print_relids can't. Print the cheapest_parameterized_paths list for a RelOptInfo, and include information about a parameterized path's required_outer rels. Noted while trying to use this feature to debug Alexander Kirkouski's recent bug report.
-rw-r--r--src/backend/optimizer/path/allpaths.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 5246260e12a..873a7647748 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -2829,7 +2829,7 @@ remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel)
#ifdef OPTIMIZER_DEBUG
static void
-print_relids(Relids relids)
+print_relids(PlannerInfo *root, Relids relids)
{
int x;
bool first = true;
@@ -2839,7 +2839,11 @@ print_relids(Relids relids)
{
if (!first)
printf(" ");
- printf("%d", x);
+ if (x < root->simple_rel_array_size &&
+ root->simple_rte_array[x])
+ printf("%s", root->simple_rte_array[x]->eref->aliasname);
+ else
+ printf("%d", x);
first = false;
}
}
@@ -3013,10 +3017,17 @@ print_path(PlannerInfo *root, Path *path, int indent)
if (path->parent)
{
printf("(");
- print_relids(path->parent->relids);
- printf(") rows=%.0f", path->parent->rows);
+ print_relids(root, path->parent->relids);
+ printf(")");
+ }
+ if (path->param_info)
+ {
+ printf(" required_outer (");
+ print_relids(root, path->param_info->ppi_req_outer);
+ printf(")");
}
- printf(" cost=%.2f..%.2f\n", path->startup_cost, path->total_cost);
+ printf(" rows=%.0f cost=%.2f..%.2f\n",
+ path->rows, path->startup_cost, path->total_cost);
if (path->pathkeys)
{
@@ -3062,7 +3073,7 @@ debug_print_rel(PlannerInfo *root, RelOptInfo *rel)
ListCell *l;
printf("RELOPTINFO (");
- print_relids(rel->relids);
+ print_relids(root, rel->relids);
printf("): rows=%.0f width=%d\n", rel->rows, rel->reltarget->width);
if (rel->baserestrictinfo)
@@ -3082,6 +3093,12 @@ debug_print_rel(PlannerInfo *root, RelOptInfo *rel)
printf("\tpath list:\n");
foreach(l, rel->pathlist)
print_path(root, lfirst(l), 1);
+ if (rel->cheapest_parameterized_paths)
+ {
+ printf("\n\tcheapest parameterized paths:\n");
+ foreach(l, rel->cheapest_parameterized_paths)
+ print_path(root, lfirst(l), 1);
+ }
if (rel->cheapest_startup_path)
{
printf("\n\tcheapest startup path:\n");