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-05-01' and l_shipdate < cast(date '1997-05-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1182143.00..1182143.02 rows=1 width=29) (actual time=19227.491..19227.491 rows=1 loops=1) Buffers: shared hit=337476 read=118550 dirtied=277 written=14 -> Hash Join (cost=102335.58..1168268.06 rows=792854 width=29) (actual time=7537.734..18619.298 rows=774552 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=337476 read=118550 dirtied=277 written=14 -> Bitmap Heap Scan on lineitem (cost=16813.58..1064906.84 rows=792854 width=12) (actual time=4863.408..12590.880 rows=774552 loops=1) Recheck Cond: ((l_shipdate >= '1997-05-01'::date) AND (l_shipdate < '1997-06-01'::date)) Buffers: shared hit=296951 read=118550 dirtied=277 written=14 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16615.37 rows=792854 width=0) (actual time=4657.472..4657.472 rows=775346 loops=1) Index Cond: ((l_shipdate >= '1997-05-01'::date) AND (l_shipdate < '1997-06-01'::date)) Buffers: shared hit=4 read=2115 written=2 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2672.500..2672.500 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40522 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..1330.598 rows=2000000 loops=1) Buffers: shared hit=40522 Total runtime: 19251.837 ms (17 rows) COMMIT; COMMIT