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 '1995-12-01' and l_shipdate < cast(date '1995-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1168868.03..1168868.04 rows=1 width=29) (actual time=7149.425..7149.425 rows=1 loops=1) Buffers: shared hit=273284 read=184323 dirtied=347 written=415 -> Hash Join (cost=101653.85..1155497.54 rows=764028 width=29) (actual time=2238.011..6768.541 rows=772148 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=273284 read=184323 dirtied=347 written=415 -> Bitmap Heap Scan on lineitem (cost=16131.85..1058515.12 rows=764028 width=12) (actual time=552.705..4354.749 rows=772148 loops=1) Recheck Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Heap Blocks: exact=414970 Buffers: shared hit=264799 read=152283 dirtied=347 written=361 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15940.84 rows=764028 width=0) (actual time=365.965..365.965 rows=779191 loops=1) Index Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Buffers: shared hit=1 read=2111 written=6 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1640.881..1640.881 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=8482 read=32040 written=54 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.018..966.403 rows=2000000 loops=1) Buffers: shared hit=8482 read=32040 written=54 Planning time: 2.896 ms Execution time: 7154.775 ms (19 rows) COMMIT; COMMIT