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 '1993-11-01' and l_shipdate < cast(date '1993-11-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1158038.38..1158038.40 rows=1 width=29) (actual time=8855.781..8855.781 rows=1 loops=1) Buffers: shared hit=157865 read=290602 dirtied=305 written=632 -> Hash Join (cost=101485.70..1144859.38 rows=753086 width=29) (actual time=2444.084..8469.386 rows=749034 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=157865 read=290602 dirtied=305 written=632 -> Bitmap Heap Scan on lineitem (cost=15963.70..1048041.09 rows=753086 width=12) (actual time=526.330..5284.462 rows=749034 loops=1) Recheck Cond: ((l_shipdate >= '1993-11-01'::date) AND (l_shipdate < '1993-12-01'::date)) Heap Blocks: exact=405892 Buffers: shared hit=157859 read=250083 dirtied=305 written=616 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15775.43 rows=753086 width=0) (actual time=330.648..330.648 rows=750368 loops=1) Index Cond: ((l_shipdate >= '1993-11-01'::date) AND (l_shipdate < '1993-12-01'::date)) Buffers: shared read=2050 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1899.129..1899.129 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=3 read=40519 written=16 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..1017.126 rows=2000000 loops=1) Buffers: shared hit=3 read=40519 written=16 Planning time: 3.616 ms Execution time: 8866.196 ms (19 rows) COMMIT; COMMIT