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 '1997-03-01' and l_shipdate < cast(date '1997-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1167167.26..1167167.28 rows=1 width=29) (actual time=8118.770..8118.770 rows=1 loops=1) Buffers: shared hit=293694 read=161996 written=4746 -> Hash Join (cost=101901.74..1153646.73 rows=772602 width=29) (actual time=2674.616..7736.850 rows=773590 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=293694 read=161996 written=4746 -> Bitmap Heap Scan on lineitem (cost=16379.74..1056535.70 rows=772602 width=12) (actual time=801.469..4539.530 rows=773590 loops=1) Recheck Cond: ((l_shipdate >= '1997-03-01'::date) AND (l_shipdate < '1997-04-01'::date)) Heap Blocks: exact=413047 Buffers: shared hit=286010 read=129155 written=4746 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16186.59 rows=772602 width=0) (actual time=540.860..540.860 rows=775235 loops=1) Index Cond: ((l_shipdate >= '1997-03-01'::date) AND (l_shipdate < '1997-04-01'::date)) Buffers: shared hit=1 read=2117 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1852.910..1852.910 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=7681 read=32841 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.028..975.801 rows=2000000 loops=1) Buffers: shared hit=7681 read=32841 Planning time: 2.919 ms Execution time: 8130.311 ms (19 rows) COMMIT; COMMIT