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 '1996-03-01' and l_shipdate < cast(date '1996-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1174201.37..1174201.38 rows=1 width=29) (actual time=9052.186..9052.186 rows=1 loops=1) Buffers: shared hit=209223 read=250000 dirtied=765 written=1195 -> Hash Join (cost=101771.48..1160712.00 rows=770821 width=29) (actual time=2141.365..8646.638 rows=771605 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=209223 read=250000 dirtied=765 written=1195 -> Bitmap Heap Scan on lineitem (cost=16249.48..1063627.68 rows=770821 width=12) (actual time=508.242..5701.105 rows=771605 loops=1) Recheck Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Heap Blocks: exact=416585 Buffers: shared hit=185446 read=233252 dirtied=765 written=1174 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16056.77 rows=770821 width=0) (actual time=326.166..326.166 rows=781882 loops=1) Index Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Buffers: shared read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1510.287..1510.287 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=23774 read=16748 written=21 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.021..828.695 rows=2000000 loops=1) Buffers: shared hit=23774 read=16748 written=21 Planning time: 3.651 ms Execution time: 9059.537 ms (19 rows) COMMIT; COMMIT