DROP TABLE IF EXISTS array_prune CASCADE;
DEALLOCATE ALL;

CREATE TABLE array_prune (id1 int, id2 int) PARTITION BY HASH(id1, id2);

CREATE TABLE array_prune_t0
  PARTITION OF array_prune FOR VALUES WITH (modulus 2, remainder 0);
CREATE TABLE array_prune_t1
  PARTITION OF array_prune FOR VALUES WITH (modulus 2, remainder 1);
INSERT INTO array_prune (id1,id2) (VALUES (1,-1), (2,-2), (3,-3));
ANALYZE array_prune;

SET plan_cache_mode TO force_generic_plan;

PREPARE test2 (int,int) AS
 SELECT 1 FROM array_prune
 WHERE id1 = ANY(ARRAY[$1]) AND id2 = ANY(ARRAY[$2]);
PREPARE test3 (int,int) AS
 SELECT 1 FROM array_prune
 WHERE id1 = $1 AND id2 = $2;
 
EXPLAIN (COSTS OFF) EXECUTE test2(1,-1);
EXPLAIN (COSTS OFF) EXECUTE test3(1,-1);

/*
 Append
   ->  Seq Scan on array_prune_t0 array_prune_1
         Filter: ((id1 = ANY (ARRAY[$1])) AND (id2 = ANY (ARRAY[$2])))
   ->  Seq Scan on array_prune_t1 array_prune_2
         Filter: ((id1 = ANY (ARRAY[$1])) AND (id2 = ANY (ARRAY[$2])))

 Append
   Subplans Removed: 1
   ->  Seq Scan on array_prune_t0 array_prune_1
         Filter: ((id1 = $1) AND (id2 = $2))
*/
