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 '1994-05-01' and l_shipdate < cast(date '1994-05-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1195364.39..1195364.41 rows=1 width=29) (actual time=17852.084..17852.084 rows=1 loops=1) Buffers: shared hit=167346 read=292944 dirtied=135 written=24815 -> Hash Join (cost=102420.66..1181330.53 rows=801935 width=29) (actual time=5418.464..17219.580 rows=772815 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=167346 read=292944 dirtied=135 written=24815 -> Bitmap Heap Scan on lineitem (cost=16898.66..1077764.99 rows=801935 width=12) (actual time=928.349..9266.344 rows=772815 loops=1) Recheck Cond: ((l_shipdate >= '1994-05-01'::date) AND (l_shipdate < '1994-06-01'::date)) Buffers: shared hit=167341 read=252424 dirtied=135 written=24164 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16698.18 rows=801935 width=0) (actual time=637.623..637.623 rows=784221 loops=1) Index Cond: ((l_shipdate >= '1994-05-01'::date) AND (l_shipdate < '1994-06-01'::date)) Buffers: shared hit=452 read=1665 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=4488.632..4488.632 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=2 read=40520 written=651 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..2309.200 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 written=651 Total runtime: 17882.794 ms (17 rows) COMMIT; COMMIT