clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1811884 fiddles created (25308 in the last week).

DROP TABLE IF EXISTS t ; CREATE TABLE t ( id integer /* PRIMARY KEY */, stuff integer, large_array_of_values float[] ) ; CREATE OR REPLACE FUNCTION random_vector() RETURNS float[] AS $$ select array_agg(random()) from generate_series (1, 1000) $$ LANGUAGE SQL ; INSERT INTO t (id, stuff, large_array_of_values) SELECT id, random()*10000, random_vector() FROM generate_series(1, 10000) AS i(id) ; CREATE INDEX idx_32 ON t(id, (large_array_of_values[32]));
10000 rows affected
 hidden batch(es)


EXPLAIN ANALYZE SELECT avg(large_array_of_values[32]) FROM t WHERE id BETWEEN 5000 and 7500 AND (large_array_of_values[32]) > 0.32 ;
QUERY PLAN
Aggregate (cost=46.94..46.95 rows=1 width=8) (actual time=54.871..54.871 rows=1 loops=1)
-> Bitmap Heap Scan on t (cost=4.91..46.89 rows=17 width=32) (actual time=0.392..1.204 rows=1732 loops=1)
Recheck Cond: ((id >= 5000) AND (id <= 7500) AND (large_array_of_values[32] > '0.32'::double precision))
Heap Blocks: exact=20
-> Bitmap Index Scan on idx_32 (cost=0.00..4.91 rows=17 width=0) (actual time=0.364..0.364 rows=1732 loops=1)
Index Cond: ((id >= 5000) AND (id <= 7500) AND (large_array_of_values[32] > '0.32'::double precision))
Planning time: 0.405 ms
Execution time: 55.013 ms
 hidden batch(es)