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 '1993-03-01' and l_shipdate < cast(date '1993-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1169202.02..1169202.03 rows=1 width=29) (actual time=8695.053..8695.054 rows=1 loops=1) Buffers: shared hit=216366 read=241591 dirtied=63 written=6370 -> Hash Join (cost=101819.13..1155720.07 rows=770397 width=29) (actual time=2635.677..8289.923 rows=774351 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=216366 read=241591 dirtied=63 written=6370 -> Bitmap Heap Scan on lineitem (cost=16297.13..1058642.11 rows=770397 width=12) (actual time=607.984..5397.539 rows=774351 loops=1) Recheck Cond: ((l_shipdate >= '1993-03-01'::date) AND (l_shipdate < '1993-04-01'::date)) Heap Blocks: exact=415313 Buffers: shared hit=207810 read=209622 dirtied=63 written=4697 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16104.54 rows=770397 width=0) (actual time=430.864..430.864 rows=779068 loops=1) Index Cond: ((l_shipdate >= '1993-03-01'::date) AND (l_shipdate < '1993-04-01'::date)) Buffers: shared hit=105 read=2014 written=78 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2014.559..2014.559 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=8553 read=31969 written=1673 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.018..1142.512 rows=2000000 loops=1) Buffers: shared hit=8553 read=31969 written=1673 Planning time: 4.270 ms Execution time: 8698.157 ms (19 rows) COMMIT; COMMIT