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-09-01' and l_shipdate < cast(date '1997-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1169357.30..1169357.31 rows=1 width=29) (actual time=7623.297..7623.297 rows=1 loops=1) Buffers: shared hit=195545 read=257132 dirtied=380 written=256 -> Hash Join (cost=101593.87..1156020.92 rows=762079 width=29) (actual time=2644.649..7244.087 rows=749172 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=195545 read=257132 dirtied=380 written=256 -> Bitmap Heap Scan on lineitem (cost=16071.87..1059067.73 rows=762079 width=12) (actual time=592.460..4471.565 rows=749172 loops=1) Recheck Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Heap Blocks: exact=410103 Buffers: shared hit=195294 read=216858 dirtied=380 written=242 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15881.36 rows=762079 width=0) (actual time=393.381..393.381 rows=757483 loops=1) Index Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared read=2049 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1621.382..1621.382 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=248 read=40274 written=14 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.016..917.834 rows=2000000 loops=1) Buffers: shared hit=248 read=40274 written=14 Planning time: 3.371 ms Execution time: 7630.248 ms (19 rows) COMMIT; COMMIT