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 '1995-02-01' and l_shipdate < cast(date '1995-02-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1139991.61..1139991.63 rows=1 width=29) (actual time=9770.945..9770.945 rows=1 loops=1) Buffers: shared hit=117952 read=318056 dirtied=103 written=25497 -> Hash Join (cost=100278.24..1127771.64 rows=698284 width=29) (actual time=2028.680..9391.497 rows=697507 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=117952 read=318056 dirtied=103 written=25497 -> Bitmap Heap Scan on lineitem (cost=14756.24..1026538.25 rows=698284 width=12) (actual time=566.424..5809.040 rows=697507 loops=1) Recheck Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Buffers: shared hit=77430 read=318053 dirtied=103 written=25497 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..14581.67 rows=698284 width=0) (actual time=369.775..369.775 rows=703913 loops=1) Index Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Buffers: shared hit=191 read=1720 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1460.516..1460.516 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40519 read=3 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..754.382 rows=2000000 loops=1) Buffers: shared hit=40519 read=3 Total runtime: 9784.822 ms (17 rows) COMMIT; COMMIT