summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-04-25 03:58:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-04-25 03:58:30 +0000
commit1fcd4b7a07a5cfb00e064c4bdd984e52cde71a5c (patch)
treeb1bf9acf968752e5cad5a8ed34f2928c9d822a30 /src/backend/optimizer/path/indxpath.c
parent79a1b00226354e2c7f1bf5c1db90661b1f5a4148 (diff)
While determining the filter clauses for an index scan (either plain
or bitmap), use pred_test to be a little smarter about cases where a filter clause is logically unnecessary. This may be overkill for the plain indexscan case, but it's definitely useful for OR'd bitmap scans.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index f55f7fc9188..0a398849f8e 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.178 2005/04/25 01:30:13 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.179 2005/04/25 03:58:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -500,8 +500,14 @@ choose_bitmap_and(Query *root, RelOptInfo *rel, List *paths)
* And we consider an index redundant if all its index conditions were
* already used by earlier indexes. (We could use pred_test() to have
* a more intelligent, but much more expensive, check --- but in most
- * cases simple equality should suffice, since after all the index
- * conditions are all coming from the same query clauses.)
+ * cases simple pointer equality should suffice, since after all the
+ * index conditions are all coming from the same RestrictInfo lists.)
+ *
+ * XXX is there any risk of throwing away a useful partial index here
+ * because we don't explicitly look at indpred? At least in simple
+ * cases, the partial index will sort before competing non-partial
+ * indexes and so it makes the right choice, but perhaps we need to
+ * work harder.
*/
/* Convert list to array so we can apply qsort */
@@ -530,7 +536,7 @@ choose_bitmap_and(Query *root, RelOptInfo *rel, List *paths)
if (IsA(newpath, IndexPath))
{
newqual = ((IndexPath *) newpath)->indexclauses;
- if (list_difference(newqual, qualsofar) == NIL)
+ if (list_difference_ptr(newqual, qualsofar) == NIL)
continue; /* redundant */
}