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 '1994-02-01' and l_shipdate < cast(date '1994-02-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1139865.26..1139865.28 rows=1 width=29) (actual time=8136.183..8136.183 rows=1 loops=1) Buffers: shared hit=176325 read=258845 written=263 -> Hash Join (cost=100544.96..1127431.90 rows=710478 width=29) (actual time=2292.185..7767.854 rows=698931 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=176325 read=258845 written=263 -> Bitmap Heap Scan on lineitem (cost=15022.96..1031252.73 rows=710478 width=12) (actual time=555.643..5361.049 rows=698931 loops=1) Recheck Cond: ((l_shipdate >= '1994-02-01'::date) AND (l_shipdate < '1994-03-01'::date)) Heap Blocks: exact=392733 Buffers: shared hit=174776 read=219869 written=257 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..14845.34 rows=710478 width=0) (actual time=366.529..366.529 rows=703103 loops=1) Index Cond: ((l_shipdate >= '1994-02-01'::date) AND (l_shipdate < '1994-03-01'::date)) Buffers: shared read=1912 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1725.166..1725.166 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1546 read=38976 written=6 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..1026.316 rows=2000000 loops=1) Buffers: shared hit=1546 read=38976 written=6 Planning time: 4.162 ms Execution time: 8139.992 ms (19 rows) COMMIT; COMMIT