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 '1997-07-01' and l_shipdate < cast(date '1997-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1178018.10..1178018.11 rows=1 width=29) (actual time=8340.035..8340.035 rows=1 loops=1) Buffers: shared hit=1099 read=454213 -> Hash Join (cost=102466.37..1164038.92 rows=798810 width=29) (actual time=1990.188..7948.877 rows=774543 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=1099 read=454213 -> Bitmap Heap Scan on lineitem (cost=16944.37..1066534.77 rows=798810 width=12) (actual time=462.013..5607.381 rows=774543 loops=1) Recheck Cond: ((l_shipdate >= '1997-07-01'::date) AND (l_shipdate < '1997-08-01'::date)) Heap Blocks: exact=412669 Buffers: shared hit=1094 read=413693 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16744.66 rows=798810 width=0) (actual time=287.730..287.730 rows=774543 loops=1) Index Cond: ((l_shipdate >= '1997-07-01'::date) AND (l_shipdate < '1997-08-01'::date)) Buffers: shared hit=671 read=1447 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1514.331..1514.331 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2 read=40520 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..713.578 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 Planning time: 4.157 ms Execution time: 8342.926 ms (19 rows) COMMIT; COMMIT