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-01-01' and l_shipdate < cast(date '1997-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1192767.96..1192767.97 rows=1 width=29) (actual time=11553.975..11553.976 rows=1 loops=1) Buffers: shared hit=253414 read=204424 dirtied=111 -> Hash Join (cost=102539.50..1178674.61 rows=805334 width=29) (actual time=3045.354..10996.500 rows=773162 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=253414 read=204424 dirtied=111 -> Bitmap Heap Scan on lineitem (cost=17017.50..1075032.60 rows=805334 width=12) (actual time=657.212..5934.853 rows=773162 loops=1) Recheck Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Buffers: shared hit=229430 read=187883 dirtied=111 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16816.17 rows=805334 width=0) (actual time=473.110..473.110 rows=779403 loops=1) Index Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Buffers: shared read=2116 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2386.299..2386.299 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=23981 read=16541 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.009..1276.587 rows=2000000 loops=1) Buffers: shared hit=23981 read=16541 Total runtime: 11564.658 ms (17 rows) COMMIT; COMMIT