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-07-01' and l_shipdate < cast(date '1995-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1182428.85..1182428.87 rows=1 width=29) (actual time=42891.790..42891.790 rows=1 loops=1) Buffers: shared hit=166268 read=294488 dirtied=403 written=3874 -> Hash Join (cost=101807.84..1168901.75 rows=772977 width=29) (actual time=6796.181..42099.216 rows=773729 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=166268 read=294488 dirtied=403 written=3874 -> Bitmap Heap Scan on lineitem (cost=16285.84..1065987.77 rows=772977 width=12) (actual time=1214.657..33093.369 rows=773729 loops=1) Recheck Cond: ((l_shipdate >= '1995-07-01'::date) AND (l_shipdate < '1995-08-01'::date)) Buffers: shared hit=160087 read=260144 dirtied=403 written=3874 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16092.60 rows=772977 width=0) (actual time=953.410..953.410 rows=784396 loops=1) Index Cond: ((l_shipdate >= '1995-07-01'::date) AND (l_shipdate < '1995-08-01'::date)) Buffers: shared read=2117 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=5579.546..5579.546 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=6178 read=34344 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..4404.611 rows=2000000 loops=1) Buffers: shared hit=6178 read=34344 Total runtime: 42907.363 ms (17 rows) COMMIT; COMMIT