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 '1996-10-01' and l_shipdate < cast(date '1996-10-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1177805.40..1177805.41 rows=1 width=29) (actual time=15980.447..15980.447 rows=1 loops=1) Buffers: shared hit=307132 read=148077 dirtied=244 written=211 -> Hash Join (cost=102132.16..1164100.20 rows=783154 width=29) (actual time=6463.256..15427.448 rows=773854 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=307132 read=148077 dirtied=244 written=211 -> Bitmap Heap Scan on lineitem (cost=16610.16..1060957.24 rows=783154 width=12) (actual time=832.724..6259.655 rows=773854 loops=1) Recheck Cond: ((l_shipdate >= '1996-10-01'::date) AND (l_shipdate < '1996-11-01'::date)) Buffers: shared hit=297824 read=116860 dirtied=244 written=211 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16414.37 rows=783154 width=0) (actual time=617.127..617.127 rows=774616 loops=1) Index Cond: ((l_shipdate >= '1996-10-01'::date) AND (l_shipdate < '1996-11-01'::date)) Buffers: shared hit=4 read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=5628.469..5628.469 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=9305 read=31217 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..1435.694 rows=2000000 loops=1) Buffers: shared hit=9305 read=31217 Total runtime: 16013.867 ms (17 rows) COMMIT; COMMIT