]> granicus.if.org Git - postgresql/commit
Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 25 Oct 2008 17:19:17 +0000 (17:19 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 25 Oct 2008 17:19:17 +0000 (17:19 +0000)
commit6571729d5490d12505ab5b6f180f15fe593c3105
tree0b736bf1aa882a2672236367c3221bd56d591b2f
parentd4a1e5b0a3cd503de0f84e4c423643e0788bb066
Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"
into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there
are Vars in the right-hand side.  This avoids a performance regression compared
to pre-8.2 releases, in cases where the OR form can be optimized into scans
of multiple indexes.  Limit the possible downside by preferring this form only
when the list isn't very long (I set the cutoff at 32 elements, which is a
bit arbitrary but in the right ballpark).  Per discussion with Jim Nasby.

In passing, also make it try the OR form if it cannot select a common type
for the array elements; we've seen a complaint or two about how the OR form
worked for such cases and ARRAY doesn't.
src/backend/parser/parse_coerce.c
src/backend/parser/parse_expr.c