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-12-01' and l_shipdate < cast(date '1995-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1185405.77..1185405.78 rows=1 width=29) (actual time=16338.562..16338.562 rows=1 loops=1) Buffers: shared hit=75356 read=383994 dirtied=513 written=15 -> Hash Join (cost=101980.36..1171741.21 rows=780832 width=29) (actual time=4184.827..15740.804 rows=772407 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=75356 read=383994 dirtied=513 written=15 -> Bitmap Heap Scan on lineitem (cost=16458.36..1068650.49 rows=780832 width=12) (actual time=808.293..8553.000 rows=772407 loops=1) Recheck Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Buffers: shared hit=75351 read=343474 dirtied=513 written=15 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16263.15 rows=780832 width=0) (actual time=573.660..573.660 rows=782561 loops=1) Index Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Buffers: shared read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=3374.748..3374.748 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=2 read=40520 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..1397.365 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 Total runtime: 16370.496 ms (17 rows) COMMIT; COMMIT