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-10-01' and l_shipdate < cast(date '1993-10-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1168501.23..1168501.24 rows=1 width=29) (actual time=30632.057..30632.058 rows=1 loops=1) Buffers: shared hit=317142 read=137739 dirtied=426 written=134 -> Hash Join (cost=101706.47..1155147.21 rows=763087 width=29) (actual time=5348.877..29942.721 rows=773435 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=317142 read=137739 dirtied=426 written=134 -> Bitmap Heap Scan on lineitem (cost=16184.47..1052455.75 rows=763087 width=12) (actual time=1211.232..21871.418 rows=773435 loops=1) Recheck Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Buffers: shared hit=311294 read=103062 dirtied=426 written=134 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15993.70 rows=763087 width=0) (actual time=932.656..932.656 rows=774133 loops=1) Index Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Buffers: shared hit=3 read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=4135.917..4135.917 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=5845 read=34677 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..2958.693 rows=2000000 loops=1) Buffers: shared hit=5845 read=34677 Total runtime: 30652.531 ms (17 rows) COMMIT; COMMIT