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 '1994-08-01' and l_shipdate < cast(date '1994-08-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1185667.27..1185667.28 rows=1 width=29) (actual time=12497.460..12497.460 rows=1 loops=1) Buffers: shared hit=314406 read=141519 dirtied=415 written=32 -> Hash Join (cost=102506.06..1171651.50 rows=800901 width=29) (actual time=4304.745..12011.842 rows=774678 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=314406 read=141519 dirtied=415 written=32 -> Bitmap Heap Scan on lineitem (cost=16984.06..1068109.23 rows=800901 width=12) (actual time=1372.214..5871.251 rows=774678 loops=1) Recheck Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Buffers: shared hit=300870 read=114530 dirtied=415 written=32 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16783.84 rows=800901 width=0) (actual time=1099.927..1099.927 rows=775452 loops=1) Index Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Buffers: shared hit=1171 read=949 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2930.545..2930.545 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=13533 read=26989 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..1129.395 rows=2000000 loops=1) Buffers: shared hit=13533 read=26989 Total runtime: 12534.122 ms (17 rows) COMMIT; COMMIT