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-08-01' and l_shipdate < cast(date '1994-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1179230.83..1179230.85 rows=1 width=29) (actual time=7202.889..7202.889 rows=1 loops=1) Buffers: shared hit=264761 read=193248 written=9 -> Hash Join (cost=102258.85..1165380.60 rows=791442 width=29) (actual time=2338.896..6822.808 rows=774785 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=264761 read=193248 written=9 -> Bitmap Heap Scan on lineitem (cost=16736.85..1067986.97 rows=791442 width=12) (actual time=810.853..4566.188 rows=774785 loops=1) Recheck Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Heap Blocks: exact=415365 Buffers: shared hit=237564 read=179920 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16538.98 rows=791442 width=0) (actual time=593.216..593.216 rows=779409 loops=1) Index Cond: ((l_shipdate >= '1994-08-01'::date) AND (l_shipdate < '1994-09-01'::date)) Buffers: shared read=2119 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1455.909..1455.909 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=27194 read=13328 written=9 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..771.202 rows=2000000 loops=1) Buffers: shared hit=27194 read=13328 written=9 Planning time: 3.330 ms Execution time: 7207.032 ms (19 rows) COMMIT; COMMIT