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-06-01' and l_shipdate < cast(date '1994-06-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1163948.10..1163948.11 rows=1 width=29) (actual time=8780.673..8780.673 rows=1 loops=1) Buffers: shared hit=137790 read=314889 written=73 -> Hash Join (cost=101320.57..1150832.48 rows=749464 width=29) (actual time=2304.731..8383.090 rows=749246 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=137790 read=314889 written=73 -> Bitmap Heap Scan on lineitem (cost=15798.57..1054068.52 rows=749464 width=12) (actual time=491.641..5763.040 rows=749246 loops=1) Recheck Cond: ((l_shipdate >= '1994-06-01'::date) AND (l_shipdate < '1994-07-01'::date)) Heap Blocks: exact=410106 Buffers: shared hit=137782 read=274372 written=35 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15611.20 rows=749464 width=0) (actual time=333.453..333.453 rows=758174 loops=1) Index Cond: ((l_shipdate >= '1994-06-01'::date) AND (l_shipdate < '1994-07-01'::date)) Buffers: shared read=2048 written=3 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1800.934..1800.934 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=5 read=40517 written=38 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..1005.262 rows=2000000 loops=1) Buffers: shared hit=5 read=40517 written=38 Planning time: 3.995 ms Execution time: 8782.666 ms (19 rows) COMMIT; COMMIT