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=1184501.16..1184501.17 rows=1 width=29) (actual time=6778.063..6778.063 rows=1 loops=1) Buffers: shared hit=266187 read=193062 written=693 -> Hash Join (cost=102378.87..1170527.95 rows=798469 width=29) (actual time=2138.669..6392.277 rows=774757 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=266187 read=193062 written=693 -> Bitmap Heap Scan on lineitem (cost=16856.87..1073028.92 rows=798469 width=12) (actual time=579.819..4109.478 rows=774757 loops=1) Recheck Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Heap Blocks: exact=416605 Buffers: shared hit=251063 read=167661 written=653 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16657.26 rows=798469 width=0) (actual time=391.176..391.176 rows=781693 loops=1) Index Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Buffers: shared read=2119 written=5 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1542.453..1542.453 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=15121 read=25401 written=40 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..816.263 rows=2000000 loops=1) Buffers: shared hit=15121 read=25401 written=40 Planning time: 3.554 ms Execution time: 6785.663 ms (19 rows) COMMIT; COMMIT