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-01-01' and l_shipdate < cast(date '1997-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1174797.55..1174797.57 rows=1 width=29) (actual time=16899.214..16899.214 rows=1 loops=1) Buffers: shared hit=234062 read=223127 dirtied=8 written=16715 -> Hash Join (cost=101766.97..1161353.89 rows=768209 width=29) (actual time=3991.077..16260.999 rows=772310 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=234062 read=223127 dirtied=8 written=16715 -> Bitmap Heap Scan on lineitem (cost=16244.97..1058547.19 rows=768209 width=12) (actual time=988.201..10450.944 rows=772310 loops=1) Recheck Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Buffers: shared hit=227622 read=189042 dirtied=8 written=13795 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16052.92 rows=768209 width=0) (actual time=734.816..734.816 rows=778201 loops=1) Index Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Buffers: shared hit=344 read=1772 written=37 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=3001.084..3001.084 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=6437 read=34085 written=2920 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..1848.989 rows=2000000 loops=1) Buffers: shared hit=6437 read=34085 written=2920 Total runtime: 16910.751 ms (17 rows) COMMIT; COMMIT