bug-hashed-saop.sql

text/plain

Filename: bug-hashed-saop.sql
Type: text/plain
Part: 3
Message: Hashed SAOP on composite type with non-hashable column errors at runtime
CREATE TABLE test (a int, b tsvector);
INSERT INTO test SELECT g, ('w' || g)::tsvector FROM generate_series(1, 1000) g;
ANALYZE test;

EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, BUFFERS OFF, SUMMARY OFF)
SELECT count(*) FROM test
WHERE (a,b) = ANY (ARRAY[(1, 'w1'::tsvector), (2, 'w2'::tsvector)]);

EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, BUFFERS OFF, SUMMARY OFF)
SELECT count(*) FROM test
WHERE (a,b) = ANY (ARRAY[
  (1, 'w1'::tsvector), (2, 'w2'::tsvector), (3, 'w3'::tsvector),
  (4, 'w4'::tsvector), (5, 'w5'::tsvector), (6, 'w6'::tsvector),
  (7, 'w7'::tsvector), (8, 'w8'::tsvector), (9, 'w9'::tsvector)
  ]);

/*
                                 QUERY PLAN                                  
-----------------------------------------------------------------------------
 Aggregate (actual rows=1.00 loops=1)
   ->  Seq Scan on test (actual rows=2.00 loops=1)
         Filter: (ROW(a, b) = ANY ('{"(1,''w1'')","(2,''w2'')"}'::record[]))
         Rows Removed by Filter: 998
 Planning Time: 0.119 ms
 Execution Time: 0.854 ms
(6 rows)

ERROR:  could not identify a hash function for type tsvector
*/