Save another little bit of planner overhead on simple queries, by having
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 24 Nov 2007 19:08:51 +0000 (19:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 24 Nov 2007 19:08:51 +0000 (19:08 +0000)
clauselist_selectivity skip some analysis that's useless when there's only
one clause in the given list.  Actually this can win even for not-so-simple
queries, because we also apply clauselist_selectivity to sublists such as the
quals matching an index; which are likely to have only a single entry even
when the total query is quite complicated.

src/backend/optimizer/path/clausesel.c

index ed416f608cd489b7a078a3996785c1d2da5269db..c7a3246953814eaf6ca4004180017aa4403c1363 100644 (file)
@@ -100,6 +100,14 @@ clauselist_selectivity(PlannerInfo *root,
        RangeQueryClause *rqlist = NULL;
        ListCell   *l;
 
+       /*
+        * If there's exactly one clause, then no use in trying to match up
+        * pairs, so just go directly to clause_selectivity().
+        */
+       if (list_length(clauses) == 1)
+               return clause_selectivity(root, (Node *) linitial(clauses),
+                                                                 varRelid, jointype);
+
        /*
         * Initial scan over clauses.  Anything that doesn't look like a potential
         * rangequery clause gets multiplied into s1 and forgotten. Anything that