From: Peter Geoghegan Date: Wed, 20 Nov 2024 18:37:08 +0000 (-0500) Subject: Refine nbtree = redundancy preprocessing comment. X-Git-Tag: REL_18_BETA1~1458 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70743376987af2393e42f3cfc2def4a472070659;p=thirdparty%2Fpostgresql.git 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. --- diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index d7603250279..896696ff724 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