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-11-01' and l_shipdate < cast(date '1995-11-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1167361.54..1167361.56 rows=1 width=29) (actual time=8091.921..8091.922 rows=1 loops=1) Buffers: shared hit=220697 read=230294 written=346 -> Hash Join (cost=101585.36..1154046.53 rows=760858 width=29) (actual time=2599.683..7699.923 rows=748603 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=220697 read=230294 written=346 -> Bitmap Heap Scan on lineitem (cost=16063.36..1057111.66 rows=760858 width=12) (actual time=773.059..5019.743 rows=748603 loops=1) Recheck Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Heap Blocks: exact=408419 Buffers: shared hit=215861 read=194605 written=286 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15873.15 rows=760858 width=0) (actual time=536.111..536.111 rows=755402 loops=1) Index Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Buffers: shared read=2047 written=3 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1812.599..1812.599 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=4833 read=35689 written=60 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..943.245 rows=2000000 loops=1) Buffers: shared hit=4833 read=35689 written=60 Planning time: 4.906 ms Execution time: 8095.181 ms (19 rows) COMMIT; COMMIT