88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.161 2007/02/22 22:00:23 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.162 2007/04/21 06:18:52 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -196,29 +196,16 @@ set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti)
196196static void
197197set_plain_rel_pathlist (PlannerInfo * root ,RelOptInfo * rel ,RangeTblEntry * rte )
198198{
199- /* Mark rel with estimated output rows, width, etc */
200- set_baserel_size_estimates (root ,rel );
201-
202- /* Test any partial indexes of rel for applicability */
203- check_partial_indexes (root ,rel );
204-
205- /*
206- * Check to see if we can extract any restriction conditions from join
207- * quals that are OR-of-AND structures. If so, add them to the rel's
208- * restriction list, and recompute the size estimates.
209- */
210- if (create_or_index_quals (root ,rel ))
211- set_baserel_size_estimates (root ,rel );
212-
213199/*
214200 * If we can prove we don't need to scan the rel via constraint exclusion,
215201 * set up a single dummy path for it. (Rather than inventing a special
216202 * "dummy" path type, we represent this as an AppendPath with no members.)
217203 */
218204if (relation_excluded_by_constraints (rel ,rte ))
219205{
220- /*Reset output-rows estimate to 0 */
206+ /*Set dummy size estimates --- we leave attr_widths[] as zeroes */
221207rel -> rows = 0 ;
208+ rel -> width = 0 ;
222209
223210add_path (rel , (Path * )create_append_path (rel ,NIL ));
224211
@@ -228,6 +215,20 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
228215return ;
229216}
230217
218+ /* Mark rel with estimated output rows, width, etc */
219+ set_baserel_size_estimates (root ,rel );
220+
221+ /* Test any partial indexes of rel for applicability */
222+ check_partial_indexes (root ,rel );
223+
224+ /*
225+ * Check to see if we can extract any restriction conditions from join
226+ * quals that are OR-of-AND structures. If so, add them to the rel's
227+ * restriction list, and recompute the size estimates.
228+ */
229+ if (create_or_index_quals (root ,rel ))
230+ set_baserel_size_estimates (root ,rel );
231+
231232/*
232233 * Generate paths and add them to the rel's pathlist.
233234 *
@@ -369,7 +370,8 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
369370/*
370371 * Propagate size information from the child back to the parent. For
371372 * simplicity, we use the largest widths from any child as the parent
372- * estimates.
373+ * estimates. (If you want to change this, beware of child
374+ * attr_widths[] entries that haven't been set and are still 0.)
373375 */
374376rel -> rows += childrel -> rows ;
375377if (childrel -> width > rel -> width )