From 70743376987af2393e42f3cfc2def4a472070659 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Wed, 20 Nov 2024 13:37:08 -0500 Subject: [PATCH] Refine nbtree = redundancy preprocessing comment. Spell out how a = key associated with a SAOP array renders a > key against the same index column redundant at the relevant point inside _bt_preprocess_keys. Follow-up to commit 5bf748b8. --- src/backend/access/nbtree/nbtutils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index d760325027..896696ff72 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -2668,8 +2668,14 @@ _bt_preprocess_keys(IndexScanDesc scan) /* * If = has been specified, all other keys can be eliminated as - * redundant. If we have a case like key = 1 AND key > 2, we can - * set qual_ok to false and abandon further processing. + * redundant. Note that this is no less true if the = key is + * SEARCHARRAY; the only real difference is that the inequality + * key _becomes_ redundant by making _bt_compare_scankey_args + * eliminate the subset of elements that won't need to be matched. + * + * If we have a case like "key = 1 AND key > 2", we set qual_ok to + * false and abandon further processing. We'll do the same thing + * given a case like "key IN (0, 1) AND key > 2". * * We also have to deal with the case of "key IS NULL", which is * unsatisfiable in combination with any other index condition. By -- 2.11.4.GIT