libraryfilecontent has 14M rows of data, so we're looking at index pages plus a table page for every row referenced.
Its possible we have table bloat happening;
(qastaging:) explain analyze select sum(filesize) from libraryfilecontent where id in (SELECT trunc(random() * 13000000 + 1) FROM generate_series(1,1000)); QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170606.21..1170606.22 rows=1 width=8) (actual time=10274.794..10274.794 rows=1 loops=1) -> Hash Join (cost=39.50..1135723.70 rows=13953003 width=8) (actual time=5.543..10273.940 rows=182 loops=1) Hash Cond: ((libraryfilecontent.id)::double precision = (trunc(((random() * 13000000::double precision) + 1::double precision)))) -> Seq Scan on libraryfilecontent (cost=0.00..368269.03 rows=13953003 width=12) (actual time=0.034..5751.479 rows=13952977 loops=1) -> Hash (cost=37.00..37.00 rows=200 width=8) (actual time=3.128..3.128 rows=1000 loops=1) -> HashAggregate (cost=35.00..37.00 rows=200 width=8) (actual time=2.116..2.497 rows=1000 loops=1) -> Function Scan on generate_series (cost=0.00..22.50 rows=1000 width=0) (actual time=0.256..1.234 rows=1000 loops=1) Total runtime: 10274.957 ms (8 rows)
Time: 10306.695 ms
libraryfilecontent has 14M rows of data, so we're looking at index pages plus a table page for every row referenced.
Its possible we have table bloat happening;
(qastaging:) series( 1,1000) );
QUERY PLAN ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- --- 21..1170606. 22 rows=1 width=8) (actual time=10274. 794..10274. 794 rows=1 loops=1) 50..1135723. 70 rows=13953003 width=8) (actual time=5. 543..10273. 940 rows=182 loops=1) ntent.id) ::double precision = (trunc(((random() * 13000000::double precision) + 1::double precision)))) 00..368269. 03 rows=13953003 width=12) (actual time=0. 034..5751. 479 rows=13952977 loops=1)
-> Function Scan on generate_series (cost=0.00..22.50 rows=1000 width=0) (actual time=0.256..1.234 rows=1000 loops=1)
explain analyze select sum(filesize) from libraryfilecontent where id in (SELECT trunc(random() * 13000000 + 1) FROM generate_
-------
Aggregate (cost=1170606.
-> Hash Join (cost=39.
Hash Cond: ((libraryfileco
-> Seq Scan on libraryfilecontent (cost=0.
-> Hash (cost=37.00..37.00 rows=200 width=8) (actual time=3.128..3.128 rows=1000 loops=1)
-> HashAggregate (cost=35.00..37.00 rows=200 width=8) (actual time=2.116..2.497 rows=1000 loops=1)
Total runtime: 10274.957 ms
(8 rows)
Time: 10306.695 ms