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-12-01' and l_shipdate < cast(date '1994-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1177264.84..1177264.86 rows=1 width=29) (actual time=7261.618..7261.618 rows=1 loops=1) Buffers: shared hit=198706 read=257369 dirtied=154 written=26 -> Hash Join (cost=102382.72..1163346.53 rows=795332 width=29) (actual time=2123.521..6854.118 rows=774316 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=198706 read=257369 dirtied=154 written=26 -> Bitmap Heap Scan on lineitem (cost=16860.72..1065894.55 rows=795332 width=12) (actual time=497.109..4480.370 rows=774316 loops=1) Recheck Cond: ((l_shipdate >= '1994-12-01'::date) AND (l_shipdate < '1995-01-01'::date)) Heap Blocks: exact=413433 Buffers: shared hit=196716 read=218834 dirtied=154 written=26 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16661.88 rows=795332 width=0) (actual time=336.927..336.927 rows=775052 loops=1) Index Cond: ((l_shipdate >= '1994-12-01'::date) AND (l_shipdate < '1995-01-01'::date)) Buffers: shared hit=2 read=2115 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1618.478..1618.478 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1987 read=38535 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..931.768 rows=2000000 loops=1) Buffers: shared hit=1987 read=38535 Planning time: 3.115 ms Execution time: 7264.283 ms (19 rows) COMMIT; COMMIT