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-09-01' and l_shipdate < cast(date '1997-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1181444.22..1181444.24 rows=1 width=29) (actual time=36260.414..36260.414 rows=1 loops=1) Buffers: shared hit=225058 read=228022 dirtied=30 written=114 -> Hash Join (cost=101841.26..1167901.04 rows=773896 width=29) (actual time=5485.523..35481.263 rows=749165 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=225058 read=228022 dirtied=30 written=114 -> Bitmap Heap Scan on lineitem (cost=16319.26..1064966.38 rows=773896 width=12) (actual time=1192.951..26800.814 rows=749165 loops=1) Recheck Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared hit=202667 read=209888 dirtied=30 written=52 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16125.79 rows=773896 width=0) (actual time=929.767..929.767 rows=758214 loops=1) Index Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared hit=3 read=2047 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=4290.885..4290.885 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=22388 read=18134 written=62 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..3005.990 rows=2000000 loops=1) Buffers: shared hit=22388 read=18134 written=62 Total runtime: 36374.598 ms (17 rows) COMMIT; COMMIT