BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#55' and p_container = 'SM PACK' and l_quantity < ( select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey ); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=115869.56..115869.57 rows=1 width=4) (actual time=210.557..210.557 rows=1 loops=1) Buffers: shared hit=73505 read=7048 dirtied=113 -> Nested Loop (cost=83.02..115818.57 rows=20396 width=4) (actual time=1.746..209.176 rows=5391 loops=1) Buffers: shared hit=73505 read=7048 dirtied=113 -> Bitmap Heap Scan on part (cost=73.26..6719.72 rows=2032 width=4) (actual time=1.377..34.528 rows=2006 loops=1) Recheck Cond: ((p_container = 'SM PACK'::bpchar) AND (p_brand = 'Brand#55'::bpchar)) Heap Blocks: exact=1955 Buffers: shared read=1970 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..72.75 rows=2032 width=0) (actual time=1.041..1.041 rows=2006 loops=1) Index Cond: ((p_container = 'SM PACK'::bpchar) AND (p_brand = 'Brand#55'::bpchar)) Buffers: shared read=15 -> Index Scan using lineitem_l_partkey_l_quantity_idx on lineitem (cost=9.76..53.59 rows=10 width=12) (actual time=0.015..0.038 rows=3 loops=2006) Index Cond: ((l_partkey = part.p_partkey) AND (l_quantity < (SubPlan 1))) Buffers: shared hit=11157 read=2278 SubPlan 1 -> Aggregate (cost=9.19..9.20 rows=1 width=4) (actual time=0.046..0.046 rows=1 loops=2006) Buffers: shared hit=62348 read=2800 dirtied=113 -> Index Only Scan using lineitem_l_partkey_l_quantity_idx on lineitem lineitem_1 (cost=0.56..9.11 rows=31 width=4) (actual time=0.024..0.041 rows=30 loops=2006) Index Cond: (l_partkey = part.p_partkey) Heap Fetches: 467 Buffers: shared hit=62348 read=2800 dirtied=113 SubPlan 1 -> Aggregate (cost=9.19..9.20 rows=1 width=4) (actual time=0.046..0.046 rows=1 loops=2006) Buffers: shared hit=62348 read=2800 dirtied=113 -> Index Only Scan using lineitem_l_partkey_l_quantity_idx on lineitem lineitem_1 (cost=0.56..9.11 rows=31 width=4) (actual time=0.024..0.041 rows=30 loops=2006) Index Cond: (l_partkey = part.p_partkey) Heap Fetches: 467 Buffers: shared hit=62348 read=2800 dirtied=113 Planning time: 2.935 ms Execution time: 210.726 ms (30 rows) COMMIT; COMMIT