mydb=> select array[11111111111,2,3] & array[11111111111,2]; ERROR: operator does not exist: bigint[] & bigint[] LINE 1: select array[11111111111,2,3] & array[11111111111,2]; ^ HINT: No operator matches the given name and argument type(s). You might need toadd explicit type casts.
mydb=> explain analyze select t2.skyid,t2.phone_list, array_length(intersection(t1.phone_list,t2.phone_list),1) mydb-> from array_test t1, array_test t2 mydb-> where t1.skyid=7 and t1.skyid!=t2.skyid and t1.phone_list && t2.phone_list mydb-> order by array_length(intersection(t1.phone_list,t2.phone_list),1) desc;
QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- Sort (cost=1070.18..1071.43 rows=500 width=110) (actual time=1.185..1.215 rows=6 loops=1) Sort Key: (array_length(intersection(t1.phone_list, t2.phone_list), 1)) Sort Method: quicksort Memory: 17kB -> Nested Loop (cost=19.88..1047.77 rows=500 width=110) (actual time=0.854..1.117 rows=6 loops=1) Join Filter: (t1.skyid <> t2.skyid) -> Index Scan using array_test_pkey on array_test t1 (cost=0.00..8.28 rows=1 width=57) (actual time=0.231..0.239 rows=1 loops=1) Index Cond: (skyid = 7) -> Bitmap Heap Scan on array_test t2 (cost=19.88..905.74 rows=500 width=57) (actual time=0.226..0.264 rows=7 loops=1) Recheck Cond: (t1.phone_list && phone_list) -> Bitmap Index Scan on idx_array_test_phone_list (cost=0.00..19.75 rows=500 width=0) (actual time=0.123..0.123 rows=7 loops=1) Index Cond: (t1.phone_list && phone_list) Total runtime: 1.399 ms (12 rows)