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-04-01' and l_shipdate < cast(date '1993-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1159226.24..1159226.26 rows=1 width=29) (actual time=11141.333..11141.334 rows=1 loops=1) Buffers: shared hit=118349 read=332659 -> Hash Join (cost=101079.05..1146349.29 rows=735826 width=29) (actual time=2149.675..10679.323 rows=749855 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=118349 read=332659 -> Bitmap Heap Scan on lineitem (cost=15557.05..1044271.20 rows=735826 width=12) (actual time=767.867..6695.123 rows=749855 loops=1) Recheck Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Buffers: shared hit=77831 read=332652 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15373.09 rows=735826 width=0) (actual time=553.580..553.580 rows=755089 loops=1) Index Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Buffers: shared hit=3 read=2049 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1380.100..1380.100 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40515 read=7 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..702.318 rows=2000000 loops=1) Buffers: shared hit=40515 read=7 Total runtime: 11152.516 ms (17 rows) COMMIT; COMMIT