Skip site navigation (1) Skip section navigation (2)

pgsql: Add a heuristic to transformAExprIn() to make it prefer expanding

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add a heuristic to transformAExprIn() to make it prefer expanding
Date: 2008-10-25 17:19:26
Message-ID: 20081025171926.6C6FE7545A4@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
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.

Tags:
----
REL8_2_STABLE

Modified Files:
--------------
    pgsql/src/backend/parser:
        parse_coerce.c (r2.146 -> r2.146.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_coerce.c?r1=2.146&r2=2.146.2.1)
        parse_expr.c (r1.198 -> r1.198.2.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_expr.c?r1=1.198&r2=1.198.2.1)

pgsql-committers by date

Next:From: Tom LaneDate: 2008-10-25 19:51:32
Subject: pgsql: Be a little smarter about qual handling for semi-joins: a qual
Previous:From: Tom LaneDate: 2008-10-25 17:19:17
Subject: pgsql: Add a heuristic to transformAExprIn() to make it prefer expanding

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group