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 '1996-05-01' and l_shipdate < cast(date '1996-05-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1168121.51..1168121.52 rows=1 width=29) (actual time=45558.877..45558.877 rows=1 loops=1) Buffers: shared hit=142310 read=318007 dirtied=163 written=11482 -> Hash Join (cost=101192.69..1155105.16 rows=743791 width=29) (actual time=6243.707..44744.954 rows=773103 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=142310 read=318007 dirtied=163 written=11482 -> Bitmap Heap Scan on lineitem (cost=15670.69..1052847.87 rows=743791 width=12) (actual time=978.474..35955.840 rows=773103 loops=1) Recheck Cond: ((l_shipdate >= '1996-05-01'::date) AND (l_shipdate < '1996-06-01'::date)) Buffers: shared hit=137633 read=282159 dirtied=163 written=11463 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15484.74 rows=743791 width=0) (actual time=775.328..775.328 rows=784418 loops=1) Index Cond: ((l_shipdate >= '1996-05-01'::date) AND (l_shipdate < '1996-06-01'::date)) Buffers: shared hit=37 read=2080 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=5263.115..5263.115 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=4674 read=35848 written=19 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..4042.921 rows=2000000 loops=1) Buffers: shared hit=4674 read=35848 written=19 Total runtime: 45574.265 ms (17 rows) COMMIT; COMMIT