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 '1993-10-01' and l_shipdate < cast(date '1993-10-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1188424.26..1188424.28 rows=1 width=29) (actual time=13166.610..13166.611 rows=1 loops=1) Buffers: shared hit=193804 read=263491 written=6840 -> Hash Join (cost=102375.15..1174474.94 rows=797104 width=29) (actual time=3808.873..12656.397 rows=773281 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=193804 read=263491 written=6840 -> Bitmap Heap Scan on lineitem (cost=16853.15..1071018.10 rows=797104 width=12) (actual time=755.720..6687.167 rows=773281 loops=1) Recheck Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Buffers: shared hit=153279 read=263491 written=6840 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16653.87 rows=797104 width=0) (actual time=525.780..525.780 rows=778589 loops=1) Index Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Buffers: shared hit=257 read=1859 written=207 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=3050.895..3050.895 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40522 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..831.586 rows=2000000 loops=1) Buffers: shared hit=40522 Total runtime: 13183.704 ms (17 rows) COMMIT; COMMIT