Repository navigation
Conversation
Generate a B-tree index condition for a folded constant IN list and retain the original membership check as a filter. Cover the index scan, mixed numeric comparison semantics, and extension upgrade in regression tests. Refs apache#2582
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2582
Summary
Generate a B-tree
= ANY(...)index condition forWHERE n.prop IN $paramwhen a custom plan folds the parameter into a constant list of integers, strings, or booleans. Retain the original membership check as a filter so that an index match between an integer and its floating-point equivalent does not change the query result.Generic plans and lists with unsupported element types continue to use the existing membership evaluation.
Reproduction and benchmark
Ran the reproduction from #2582 on PostgreSQL 18.6 and AGE 1.8.0, with 20,000 product vertices, 10,000 edges, and a B-tree expression index on
pid. Executed the same prepared query with{"pids": [16, 4242, 9000]}andplan_cache_mode = force_custom_plan.product_pidindex scan with 3 searches and a membership filterBoth versions returned
17,4243, and9001. Withplan_cache_mode = auto, the patched query used custom plans for all 12 executions in this reproduction.Tests
make installcheckon PostgreSQL 18.6: all 44 tests passed onmaster, including the extension upgrade test.