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 '1996-07-01' and l_shipdate < cast(date '1996-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1174551.91..1174551.92 rows=1 width=29) (actual time=7759.271..7759.271 rows=1 loops=1) Buffers: shared hit=172788 read=284872 written=162 -> Hash Join (cost=101950.99..1160940.44 rows=777798 width=29) (actual time=2191.676..7362.827 rows=772743 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=172788 read=284872 written=162 -> Bitmap Heap Scan on lineitem (cost=16428.99..1063751.47 rows=777798 width=12) (actual time=507.817..4944.695 rows=772743 loops=1) Recheck Cond: ((l_shipdate >= '1996-07-01'::date) AND (l_shipdate < '1996-08-01'::date)) Heap Blocks: exact=415023 Buffers: shared hit=171369 read=245766 written=136 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16234.55 rows=777798 width=0) (actual time=346.292..346.292 rows=778784 loops=1) Index Cond: ((l_shipdate >= '1996-07-01'::date) AND (l_shipdate < '1996-08-01'::date)) Buffers: shared read=2112 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1672.349..1672.349 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1416 read=39106 written=26 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..985.298 rows=2000000 loops=1) Buffers: shared hit=1416 read=39106 written=26 Planning time: 3.579 ms Execution time: 7762.649 ms (19 rows) COMMIT; COMMIT