1 /*-------------------------------------------------------------------------
4 * Routines to find possible search paths for processing a query
6 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.109 2003/11/29 19:51:50 pgsql Exp $
13 *-------------------------------------------------------------------------
18 #ifdef OPTIMIZER_DEBUG
19 #include "nodes/print.h"
21 #include "optimizer/clauses.h"
22 #include "optimizer/cost.h"
23 #include "optimizer/geqo.h"
24 #include "optimizer/pathnode.h"
25 #include "optimizer/paths.h"
26 #include "optimizer/plancat.h"
27 #include "optimizer/planner.h"
28 #include "optimizer/prep.h"
29 #include "optimizer/var.h"
30 #include "parser/parsetree.h"
31 #include "parser/parse_clause.h"
32 #include "rewrite/rewriteManip.h"
35 /* These parameters are set by GUC */
36 bool enable_geqo = false; /* just in case GUC doesn't set it */
40 static void set_base_rel_pathlists(Query *root);
41 static void set_plain_rel_pathlist(Query *root, RelOptInfo *rel,
43 static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
44 Index rti, RangeTblEntry *rte,
46 static void set_subquery_pathlist(Query *root, RelOptInfo *rel,
47 Index rti, RangeTblEntry *rte);
48 static void set_function_pathlist(Query *root, RelOptInfo *rel,
50 static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed,
52 static bool subquery_is_pushdown_safe(Query *subquery, Query *topquery,
53 bool *differentTypes);
54 static bool recurse_pushdown_safe(Node *setOp, Query *topquery,
55 bool *differentTypes);
56 static void compare_tlist_datatypes(List *tlist, List *colTypes,
57 bool *differentTypes);
58 static bool qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
59 bool *differentTypes);
60 static void subquery_push_qual(Query *subquery, Index rti, Node *qual);
61 static void recurse_push_qual(Node *setOp, Query *topquery,
62 Index rti, Node *qual);
67 * Finds all possible access paths for executing a query, returning a
68 * single rel that represents the join of all base rels in the query.
71 make_one_rel(Query *root)
76 * Generate access paths for the base rels.
78 set_base_rel_pathlists(root);
81 * Generate access paths for the entire join tree.
83 Assert(root->jointree != NULL && IsA(root->jointree, FromExpr));
85 rel = make_fromexpr_rel(root, root->jointree);
88 * The result should join all the query's base rels.
90 Assert(bms_num_members(rel->relids) == length(root->base_rel_list));
96 * set_base_rel_pathlists
97 * Finds all paths available for scanning each base-relation entry.
98 * Sequential scan and any available indices are considered.
99 * Each useful path is attached to its relation's 'pathlist' field.
102 set_base_rel_pathlists(Query *root)
106 foreach(rellist, root->base_rel_list)
108 RelOptInfo *rel = (RelOptInfo *) lfirst(rellist);
109 Index rti = rel->relid;
113 Assert(rti > 0); /* better be base rel */
114 rte = rt_fetch(rti, root->rtable);
116 if (rel->rtekind == RTE_SUBQUERY)
118 /* Subquery --- generate a separate plan for it */
119 set_subquery_pathlist(root, rel, rti, rte);
121 else if (rel->rtekind == RTE_FUNCTION)
123 /* RangeFunction --- generate a separate plan for it */
124 set_function_pathlist(root, rel, rte);
126 else if ((inheritlist = expand_inherited_rtentry(root, rti, true))
129 /* Relation is root of an inheritance tree, process specially */
130 set_inherited_rel_pathlist(root, rel, rti, rte, inheritlist);
135 set_plain_rel_pathlist(root, rel, rte);
138 #ifdef OPTIMIZER_DEBUG
139 debug_print_rel(root, rel);
145 * set_plain_rel_pathlist
146 * Build access paths for a plain relation (no subquery, no inheritance)
149 set_plain_rel_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte)
151 /* Mark rel with estimated output rows, width, etc */
152 set_baserel_size_estimates(root, rel);
155 * Generate paths and add them to the rel's pathlist.
157 * Note: add_path() will discard any paths that are dominated by another
158 * available path, keeping only those paths that are superior along at
159 * least one dimension of cost or sortedness.
162 /* Consider sequential scan */
163 add_path(rel, create_seqscan_path(root, rel));
165 /* Consider TID scans */
166 create_tidscan_paths(root, rel);
168 /* Consider index paths for both simple and OR index clauses */
169 create_index_paths(root, rel);
171 /* create_index_paths must be done before create_or_index_paths */
172 create_or_index_paths(root, rel);
174 /* Now find the cheapest of the paths for this rel */
179 * set_inherited_rel_pathlist
180 * Build access paths for a inheritance tree rooted at rel
182 * inheritlist is a list of RT indexes of all tables in the inheritance tree,
183 * including a duplicate of the parent itself. Note we will not come here
184 * unless there's at least one child in addition to the parent.
186 * NOTE: the passed-in rel and RTE will henceforth represent the appended
187 * result of the whole inheritance tree. The members of inheritlist represent
188 * the individual tables --- in particular, the inheritlist member that is a
189 * duplicate of the parent RTE represents the parent table alone.
190 * We will generate plans to scan the individual tables that refer to
191 * the inheritlist RTEs, whereas Vars elsewhere in the plan tree that
192 * refer to the original RTE are taken to refer to the append output.
193 * In particular, this means we have separate RelOptInfos for the parent
194 * table and for the append output, which is a good thing because they're
198 set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
199 Index rti, RangeTblEntry *rte,
202 int parentRTindex = rti;
203 Oid parentOID = rte->relid;
204 List *subpaths = NIL;
208 * XXX for now, can't handle inherited expansion of FOR UPDATE; can we
211 if (intMember(parentRTindex, root->rowMarks))
213 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
214 errmsg("SELECT FOR UPDATE is not supported for inheritance queries")));
217 * The executor will check the parent table's access permissions when
218 * it examines the parent's inheritlist entry. There's no need to
219 * check twice, so turn off access check bits in the original RTE.
221 rte->checkForRead = false;
222 rte->checkForWrite = false;
225 * Initialize to compute size estimates for whole inheritance tree
231 * Generate access paths for each table in the tree (parent AND
232 * children), and pick the cheapest path for each table.
234 foreach(il, inheritlist)
236 int childRTindex = lfirsti(il);
237 RangeTblEntry *childrte;
239 RelOptInfo *childrel;
244 childrte = rt_fetch(childRTindex, root->rtable);
245 childOID = childrte->relid;
248 * Make a RelOptInfo for the child so we can do planning. Do NOT
249 * attach the RelOptInfo to the query's base_rel_list, however,
250 * since the child is not part of the main join tree. Instead,
251 * the child RelOptInfo is added to other_rel_list.
253 childrel = build_other_rel(root, childRTindex);
256 * Copy the parent's targetlist and restriction quals to the
257 * child, with attribute-number adjustment as needed. We don't
258 * bother to copy the join quals, since we can't do any joining of
259 * the individual tables. Also, we just zap attr_needed rather
260 * than trying to adjust it; it won't be looked at in the child.
262 reltlist = FastListValue(&rel->reltargetlist);
264 adjust_inherited_attrs((Node *) reltlist,
269 FastListFromList(&childrel->reltargetlist, reltlist);
270 childrel->attr_needed = NULL;
271 childrel->baserestrictinfo = (List *)
272 adjust_inherited_attrs((Node *) rel->baserestrictinfo,
279 * Now compute child access paths, and save the cheapest.
281 set_plain_rel_pathlist(root, childrel, childrte);
283 subpaths = lappend(subpaths, childrel->cheapest_total_path);
286 * Propagate size information from the child back to the parent.
287 * For simplicity, we use the largest widths from any child as the
290 rel->rows += childrel->rows;
291 if (childrel->width > rel->width)
292 rel->width = childrel->width;
294 childvars = FastListValue(&childrel->reltargetlist);
295 foreach(parentvars, FastListValue(&rel->reltargetlist))
297 Var *parentvar = (Var *) lfirst(parentvars);
298 Var *childvar = (Var *) lfirst(childvars);
299 int parentndx = parentvar->varattno - rel->min_attr;
300 int childndx = childvar->varattno - childrel->min_attr;
302 if (childrel->attr_widths[childndx] > rel->attr_widths[parentndx])
303 rel->attr_widths[parentndx] = childrel->attr_widths[childndx];
304 childvars = lnext(childvars);
309 * Finally, build Append path and install it as the only access path
310 * for the parent rel.
312 add_path(rel, (Path *) create_append_path(rel, subpaths));
314 /* Select cheapest path (pretty easy in this case...) */
319 * set_subquery_pathlist
320 * Build the (single) access path for a subquery RTE
323 set_subquery_pathlist(Query *root, RelOptInfo *rel,
324 Index rti, RangeTblEntry *rte)
326 Query *subquery = rte->subquery;
327 bool *differentTypes;
330 /* We need a workspace for keeping track of set-op type coercions */
331 differentTypes = (bool *)
332 palloc0((length(subquery->targetList) + 1) * sizeof(bool));
335 * If there are any restriction clauses that have been attached to the
336 * subquery relation, consider pushing them down to become HAVING
337 * quals of the subquery itself. (Not WHERE clauses, since they may
338 * refer to subquery outputs that are aggregate results. But
339 * planner.c will transfer them into the subquery's WHERE if they do
340 * not.) This transformation is useful because it may allow us to
341 * generate a better plan for the subquery than evaluating all the
342 * subquery output rows and then filtering them.
344 * There are several cases where we cannot push down clauses.
345 * Restrictions involving the subquery are checked by
346 * subquery_is_pushdown_safe(). Restrictions on individual clauses
347 * are checked by qual_is_pushdown_safe().
349 * Non-pushed-down clauses will get evaluated as qpquals of the
352 * XXX Are there any cases where we want to make a policy decision not to
353 * push down a pushable qual, because it'd result in a worse plan?
355 if (rel->baserestrictinfo != NIL &&
356 subquery_is_pushdown_safe(subquery, subquery, differentTypes))
358 /* OK to consider pushing down individual quals */
359 List *upperrestrictlist = NIL;
362 foreach(lst, rel->baserestrictinfo)
364 RestrictInfo *rinfo = (RestrictInfo *) lfirst(lst);
365 Node *clause = (Node *) rinfo->clause;
367 if (qual_is_pushdown_safe(subquery, rti, clause, differentTypes))
370 subquery_push_qual(subquery, rti, clause);
374 /* Keep it in the upper query */
375 upperrestrictlist = lappend(upperrestrictlist, rinfo);
378 rel->baserestrictinfo = upperrestrictlist;
381 pfree(differentTypes);
383 /* Generate the plan for the subquery */
384 rel->subplan = subquery_planner(subquery, 0.0 /* default case */ );
386 /* Copy number of output rows from subplan */
387 rel->tuples = rel->subplan->plan_rows;
389 /* Mark rel with estimated output rows, width, etc */
390 set_baserel_size_estimates(root, rel);
392 /* Convert subquery pathkeys to outer representation */
393 pathkeys = build_subquery_pathkeys(root, rel, subquery);
395 /* Generate appropriate path */
396 add_path(rel, create_subqueryscan_path(rel, pathkeys));
398 /* Select cheapest path (pretty easy in this case...) */
403 * set_function_pathlist
404 * Build the (single) access path for a function RTE
407 set_function_pathlist(Query *root, RelOptInfo *rel, RangeTblEntry *rte)
409 /* Mark rel with estimated output rows, width, etc */
410 set_function_size_estimates(root, rel);
412 /* Generate appropriate path */
413 add_path(rel, create_functionscan_path(root, rel));
415 /* Select cheapest path (pretty easy in this case...) */
421 * Build access paths for a FromExpr jointree node.
424 make_fromexpr_rel(Query *root, FromExpr *from)
427 List *initial_rels = NIL;
431 * Count the number of child jointree nodes. This is the depth of the
432 * dynamic-programming algorithm we must employ to consider all ways
433 * of joining the child nodes.
435 levels_needed = length(from->fromlist);
437 if (levels_needed <= 0)
438 return NULL; /* nothing to do? */
441 * Construct a list of rels corresponding to the child jointree nodes.
442 * This may contain both base rels and rels constructed according to
443 * explicit JOIN directives.
445 foreach(jt, from->fromlist)
447 Node *jtnode = (Node *) lfirst(jt);
449 initial_rels = lappend(initial_rels,
450 make_jointree_rel(root, jtnode));
453 if (levels_needed == 1)
456 * Single jointree node, so we're done.
458 return (RelOptInfo *) lfirst(initial_rels);
463 * Consider the different orders in which we could join the rels,
464 * using either GEQO or regular optimizer.
466 if (enable_geqo && levels_needed >= geqo_threshold)
467 return geqo(root, levels_needed, initial_rels);
469 return make_one_rel_by_joins(root, levels_needed, initial_rels);
474 * make_one_rel_by_joins
475 * Find all possible joinpaths for a query by successively finding ways
476 * to join component relations into join relations.
478 * 'levels_needed' is the number of iterations needed, ie, the number of
479 * independent jointree items in the query. This is > 1.
481 * 'initial_rels' is a list of RelOptInfo nodes for each independent
482 * jointree item. These are the components to be joined together.
484 * Returns the final level of join relations, i.e., the relation that is
485 * the result of joining all the original relations together.
488 make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels)
495 * We employ a simple "dynamic programming" algorithm: we first find
496 * all ways to build joins of two jointree items, then all ways to
497 * build joins of three items (from two-item joins and single items),
498 * then four-item joins, and so on until we have considered all ways
499 * to join all the items into one rel.
501 * joinitems[j] is a list of all the j-item rels. Initially we set
502 * joinitems[1] to represent all the single-jointree-item relations.
504 joinitems = (List **) palloc0((levels_needed + 1) * sizeof(List *));
506 joinitems[1] = initial_rels;
508 for (lev = 2; lev <= levels_needed; lev++)
513 * Determine all possible pairs of relations to be joined at this
514 * level, and build paths for making each one from every available
515 * pair of lower-level relations.
517 joinitems[lev] = make_rels_by_joins(root, lev, joinitems);
520 * Do cleanup work on each just-processed rel.
522 foreach(x, joinitems[lev])
524 rel = (RelOptInfo *) lfirst(x);
529 * * for each expensive predicate in each path in each
530 * distinct rel, * consider doing pullup -- JMH
532 if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
533 xfunc_trypullup(rel);
536 /* Find and save the cheapest paths for this rel */
539 #ifdef OPTIMIZER_DEBUG
540 debug_print_rel(root, rel);
546 * We should have a single rel at the final level.
548 Assert(length(joinitems[levels_needed]) == 1);
550 rel = (RelOptInfo *) lfirst(joinitems[levels_needed]);
555 /*****************************************************************************
556 * PUSHING QUALS DOWN INTO SUBQUERIES
557 *****************************************************************************/
560 * subquery_is_pushdown_safe - is a subquery safe for pushing down quals?
562 * subquery is the particular component query being checked. topquery
563 * is the top component of a set-operations tree (the same Query if no
564 * set-op is involved).
566 * Conditions checked here:
568 * 1. If the subquery has a LIMIT clause, we must not push down any quals,
569 * since that could change the set of rows returned.
571 * 2. If the subquery contains EXCEPT or EXCEPT ALL set ops we cannot push
572 * quals into it, because that would change the results.
574 * 3. For subqueries using UNION/UNION ALL/INTERSECT/INTERSECT ALL, we can
575 * push quals into each component query, but the quals can only reference
576 * subquery columns that suffer no type coercions in the set operation.
577 * Otherwise there are possible semantic gotchas. So, we check the
578 * component queries to see if any of them have different output types;
579 * differentTypes[k] is set true if column k has different type in any
583 subquery_is_pushdown_safe(Query *subquery, Query *topquery,
584 bool *differentTypes)
586 SetOperationStmt *topop;
589 if (subquery->limitOffset != NULL || subquery->limitCount != NULL)
592 /* Are we at top level, or looking at a setop component? */
593 if (subquery == topquery)
595 /* Top level, so check any component queries */
596 if (subquery->setOperations != NULL)
597 if (!recurse_pushdown_safe(subquery->setOperations, topquery,
603 /* Setop component must not have more components (too weird) */
604 if (subquery->setOperations != NULL)
606 /* Check whether setop component output types match top level */
607 topop = (SetOperationStmt *) topquery->setOperations;
608 Assert(topop && IsA(topop, SetOperationStmt));
609 compare_tlist_datatypes(subquery->targetList,
617 * Helper routine to recurse through setOperations tree
620 recurse_pushdown_safe(Node *setOp, Query *topquery,
621 bool *differentTypes)
623 if (IsA(setOp, RangeTblRef))
625 RangeTblRef *rtr = (RangeTblRef *) setOp;
626 RangeTblEntry *rte = rt_fetch(rtr->rtindex, topquery->rtable);
627 Query *subquery = rte->subquery;
629 Assert(subquery != NULL);
630 return subquery_is_pushdown_safe(subquery, topquery, differentTypes);
632 else if (IsA(setOp, SetOperationStmt))
634 SetOperationStmt *op = (SetOperationStmt *) setOp;
636 /* EXCEPT is no good */
637 if (op->op == SETOP_EXCEPT)
640 if (!recurse_pushdown_safe(op->larg, topquery, differentTypes))
642 if (!recurse_pushdown_safe(op->rarg, topquery, differentTypes))
647 elog(ERROR, "unrecognized node type: %d",
648 (int) nodeTag(setOp));
654 * Compare tlist's datatypes against the list of set-operation result types.
655 * For any items that are different, mark the appropriate element of
656 * differentTypes[] to show that this column will have type conversions.
659 compare_tlist_datatypes(List *tlist, List *colTypes,
660 bool *differentTypes)
666 TargetEntry *tle = (TargetEntry *) lfirst(i);
668 if (tle->resdom->resjunk)
669 continue; /* ignore resjunk columns */
671 elog(ERROR, "wrong number of tlist entries");
672 if (tle->resdom->restype != lfirsto(colTypes))
673 differentTypes[tle->resdom->resno] = true;
674 colTypes = lnext(colTypes);
677 elog(ERROR, "wrong number of tlist entries");
681 * qual_is_pushdown_safe - is a particular qual safe to push down?
683 * qual is a restriction clause applying to the given subquery (whose RTE
684 * has index rti in the parent query).
686 * Conditions checked here:
688 * 1. The qual must not contain any subselects (mainly because I'm not sure
689 * it will work correctly: sublinks will already have been transformed into
690 * subplans in the qual, but not in the subquery).
692 * 2. The qual must not refer to any subquery output columns that were
693 * found to have inconsistent types across a set operation tree by
694 * subquery_is_pushdown_safe().
696 * 3. If the subquery uses DISTINCT ON, we must not push down any quals that
697 * refer to non-DISTINCT output columns, because that could change the set
698 * of rows returned. This condition is vacuous for DISTINCT, because then
699 * there are no non-DISTINCT output columns, but unfortunately it's fairly
700 * expensive to tell the difference between DISTINCT and DISTINCT ON in the
701 * parsetree representation. It's cheaper to just make sure all the Vars
702 * in the qual refer to DISTINCT columns.
704 * 4. We must not push down any quals that refer to subselect outputs that
705 * return sets, else we'd introduce functions-returning-sets into the
706 * subquery's WHERE/HAVING quals.
709 qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual,
710 bool *differentTypes)
715 Bitmapset *tested = NULL;
717 /* Refuse subselects (point 1) */
718 if (contain_subplans(qual))
722 * Examine all Vars used in clause; since it's a restriction clause,
723 * all such Vars must refer to subselect output columns.
725 vars = pull_var_clause(qual, false);
728 Var *var = (Var *) lfirst(vl);
731 Assert(var->varno == rti);
734 * We use a bitmapset to avoid testing the same attno more than
735 * once. (NB: this only works because subquery outputs can't have
738 if (bms_is_member(var->varattno, tested))
740 tested = bms_add_member(tested, var->varattno);
743 if (differentTypes[var->varattno])
749 /* Must find the tlist element referenced by the Var */
750 tle = get_tle_by_resno(subquery->targetList, var->varattno);
752 Assert(!tle->resdom->resjunk);
754 /* If subquery uses DISTINCT or DISTINCT ON, check point 3 */
755 if (subquery->distinctClause != NIL &&
756 !targetIsInSortList(tle, subquery->distinctClause))
758 /* non-DISTINCT column, so fail */
763 /* Refuse functions returning sets (point 4) */
764 if (expression_returns_set((Node *) tle->expr))
778 * subquery_push_qual - push down a qual that we have determined is safe
781 subquery_push_qual(Query *subquery, Index rti, Node *qual)
783 if (subquery->setOperations != NULL)
785 /* Recurse to push it separately to each component query */
786 recurse_push_qual(subquery->setOperations, subquery, rti, qual);
791 * We need to replace Vars in the qual (which must refer to
792 * outputs of the subquery) with copies of the subquery's
793 * targetlist expressions. Note that at this point, any uplevel
794 * Vars in the qual should have been replaced with Params, so they
797 * This step also ensures that when we are pushing into a setop tree,
798 * each component query gets its own copy of the qual.
800 qual = ResolveNew(qual, rti, 0,
801 subquery->targetList,
803 subquery->havingQual = make_and_qual(subquery->havingQual,
807 * We need not change the subquery's hasAggs or hasSublinks flags,
808 * since we can't be pushing down any aggregates that weren't
809 * there before, and we don't push down subselects at all.
815 * Helper routine to recurse through setOperations tree
818 recurse_push_qual(Node *setOp, Query *topquery,
819 Index rti, Node *qual)
821 if (IsA(setOp, RangeTblRef))
823 RangeTblRef *rtr = (RangeTblRef *) setOp;
824 RangeTblEntry *rte = rt_fetch(rtr->rtindex, topquery->rtable);
825 Query *subquery = rte->subquery;
827 Assert(subquery != NULL);
828 subquery_push_qual(subquery, rti, qual);
830 else if (IsA(setOp, SetOperationStmt))
832 SetOperationStmt *op = (SetOperationStmt *) setOp;
834 recurse_push_qual(op->larg, topquery, rti, qual);
835 recurse_push_qual(op->rarg, topquery, rti, qual);
839 elog(ERROR, "unrecognized node type: %d",
840 (int) nodeTag(setOp));
844 /*****************************************************************************
846 *****************************************************************************/
848 #ifdef OPTIMIZER_DEBUG
851 print_relids(Relids relids)
857 tmprelids = bms_copy(relids);
858 while ((x = bms_first_member(tmprelids)) >= 0)
869 print_restrictclauses(Query *root, List *clauses)
875 RestrictInfo *c = lfirst(l);
877 print_expr((Node *) c->clause, root->rtable);
884 print_path(Query *root, Path *path, int indent)
888 Path *subpath = NULL;
891 switch (nodeTag(path))
907 subpath = ((ResultPath *) path)->subpath;
911 subpath = ((MaterialPath *) path)->subpath;
915 subpath = ((UniquePath *) path)->subpath;
934 for (i = 0; i < indent; i++)
941 print_relids(path->parent->relids);
942 printf(") rows=%.0f", path->parent->rows);
944 printf(" cost=%.2f..%.2f\n", path->startup_cost, path->total_cost);
948 for (i = 0; i < indent; i++)
950 printf(" pathkeys: ");
951 print_pathkeys(path->pathkeys, root->rtable);
956 JoinPath *jp = (JoinPath *) path;
958 for (i = 0; i < indent; i++)
960 printf(" clauses: ");
961 print_restrictclauses(root, jp->joinrestrictinfo);
964 if (IsA(path, MergePath))
966 MergePath *mp = (MergePath *) path;
968 if (mp->outersortkeys || mp->innersortkeys)
970 for (i = 0; i < indent; i++)
972 printf(" sortouter=%d sortinner=%d\n",
973 ((mp->outersortkeys) ? 1 : 0),
974 ((mp->innersortkeys) ? 1 : 0));
978 print_path(root, jp->outerjoinpath, indent + 1);
979 print_path(root, jp->innerjoinpath, indent + 1);
983 print_path(root, subpath, indent + 1);
987 debug_print_rel(Query *root, RelOptInfo *rel)
991 printf("RELOPTINFO (");
992 print_relids(rel->relids);
993 printf("): rows=%.0f width=%d\n", rel->rows, rel->width);
995 if (rel->baserestrictinfo)
997 printf("\tbaserestrictinfo: ");
998 print_restrictclauses(root, rel->baserestrictinfo);
1002 foreach(l, rel->joininfo)
1004 JoinInfo *j = (JoinInfo *) lfirst(l);
1006 printf("\tjoininfo (");
1007 print_relids(j->unjoined_relids);
1009 print_restrictclauses(root, j->jinfo_restrictinfo);
1013 printf("\tpath list:\n");
1014 foreach(l, rel->pathlist)
1015 print_path(root, lfirst(l), 1);
1016 printf("\n\tcheapest startup path:\n");
1017 print_path(root, rel->cheapest_startup_path, 1);
1018 printf("\n\tcheapest total path:\n");
1019 print_path(root, rel->cheapest_total_path, 1);
1024 #endif /* OPTIMIZER_DEBUG */