aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2023-02-19 00:41:18 +0100
committerTomas Vondra <tomas.vondra@postgresql.org>2023-02-19 01:46:58 +0100
commite72910f8080185b6ade9ef7caa5c891dba3cb51c (patch)
tree377b13db61cb502e9e4949c9a979322f53860d50
parent393430f57544dfd550135e0191cc91139926b682 (diff)
downloadpostgresql-e72910f8080185b6ade9ef7caa5c891dba3cb51c.tar.gz
postgresql-e72910f8080185b6ade9ef7caa5c891dba3cb51c.zip
Fix handling of multi-column BRIN indexes
When evaluating clauses on multiple scan keys of a multi-column BRIN index, we can stop processing as soon as we find a scan key eliminating the range, and the range should not be added to tbe bitmap. That's how it worked before 14, but since a681e3c107a the code treated the range as matching if it matched at least the last scan key. Backpatch to 14, where this code was introduced. Backpatch-through: 14 Discussion: https://postgr.es/m/ebc18613-125e-60df-7520-fcbe0f9274fc%40enterprisedb.com
-rw-r--r--src/backend/access/brin/brin.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index de1427a1e0e..b5a5fa7b334 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -686,6 +686,13 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
break;
}
}
+
+ /*
+ * If we found a scan key eliminating the range, no need to
+ * check additional ones.
+ */
+ if (!addrange)
+ break;
}
}
}