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-03-01' and l_shipdate < cast(date '1996-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1188057.66..1188057.68 rows=1 width=29) (actual time=15176.239..15176.239 rows=1 loops=1) Buffers: shared hit=236486 read=220286 written=243 -> Hash Join (cost=102399.70..1174093.73 rows=797939 width=29) (actual time=2985.589..14507.596 rows=772637 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=236486 read=220286 written=243 -> Bitmap Heap Scan on lineitem (cost=16877.70..1070618.10 rows=797939 width=12) (actual time=758.535..9364.029 rows=772637 loops=1) Recheck Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Buffers: shared hit=218119 read=198128 written=230 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16678.22 rows=797939 width=0) (actual time=494.454..494.454 rows=777181 loops=1) Index Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Buffers: shared hit=3 read=2111 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2225.233..2225.233 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=18364 read=22158 written=13 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.017..1258.998 rows=2000000 loops=1) Buffers: shared hit=18364 read=22158 written=13 Total runtime: 15196.614 ms (17 rows) COMMIT; COMMIT