From 1fcd4b7a07a5cfb00e064c4bdd984e52cde71a5c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 25 Apr 2005 03:58:30 +0000 Subject: 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. --- src/backend/optimizer/path/indxpath.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/backend/optimizer/path/indxpath.c') 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 */ } -- cgit v1.2.3