BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date '1995-03-01' and l_shipdate < cast(date '1995-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1180020.55..1180020.57 rows=1 width=29) (actual time=7231.865..7231.865 rows=1 loops=1) Buffers: shared hit=245356 read=211993 dirtied=198 written=69 -> Hash Join (cost=102338.40..1166109.61 rows=794911 width=29) (actual time=2254.576..6825.164 rows=775344 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=245356 read=211993 dirtied=198 written=69 -> Bitmap Heap Scan on lineitem (cost=16816.40..1068663.94 rows=794911 width=12) (actual time=462.972..4198.229 rows=775344 loops=1) Recheck Cond: ((l_shipdate >= '1995-03-01'::date) AND (l_shipdate < '1995-04-01'::date)) Heap Blocks: exact=414704 Buffers: shared hit=245352 read=171472 dirtied=198 written=60 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16617.67 rows=794911 width=0) (actual time=310.403..310.403 rows=779193 loops=1) Index Cond: ((l_shipdate >= '1995-03-01'::date) AND (l_shipdate < '1995-04-01'::date)) Buffers: shared read=2120 written=7 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1776.444..1776.444 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1 read=40521 written=9 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.008..955.856 rows=2000000 loops=1) Buffers: shared hit=1 read=40521 written=9 Planning time: 3.524 ms Execution time: 7358.330 ms (19 rows) COMMIT; COMMIT