Skip to content

Use property indexes for parameterized IN lists in custom plans (#2582) - #2633

Open
NotHimmel wants to merge 1 commit into
apache:masterfrom
NotHimmel:fix/issue-2582-parameterized-in
Open

NotHimmel wants to merge 1 commit into
apache:masterfrom
NotHimmel:fix/issue-2582-parameterized-in

Conversation

@NotHimmel

Copy link
Copy Markdown
Contributor

Refs #2582

Summary

Generate a B-tree = ANY(...) index condition for WHERE n.prop IN $param when 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]} and plan_cache_mode = force_custom_plan.

Before After
Start vertex scan Sequential scan with 19,997 rows removed by the filter product_pid index scan with 3 searches and a membership filter
Median execution time (15 warm runs) 21.290 ms 0.074 ms

Both versions returned 17, 4243, and 9001. With plan_cache_mode = auto, the patched query used custom plans for all 12 executions in this reproduction.

Tests

  • make installcheck on PostgreSQL 18.6: all 44 tests passed on master, including the extension upgrade test.
  • Added regression coverage for index selection, mixed numeric types, duplicate elements, empty and null lists, and non-list input. The test also checks that a generic plan evaluates each supplied list correctly.

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
@NotHimmel NotHimmel changed the title Use property indexes for parameterized IN lists in custom plans Use property indexes for parameterized IN lists in custom plans (#2582) Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant