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-04-01' and l_shipdate < cast(date '1994-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1164907.77..1164907.79 rows=1 width=29) (actual time=7959.135..7959.135 rows=1 loops=1) Buffers: shared hit=133481 read=318712 dirtied=416 written=108 -> Hash Join (cost=101360.61..1151757.94 rows=751419 width=29) (actual time=2231.196..7591.068 rows=746815 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=133481 read=318712 dirtied=416 written=108 -> Bitmap Heap Scan on lineitem (cost=15838.61..1054964.65 rows=751419 width=12) (actual time=499.887..4791.866 rows=746815 loops=1) Recheck Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Heap Blocks: exact=409623 Buffers: shared hit=133400 read=278268 dirtied=416 written=108 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15650.76 rows=751419 width=0) (actual time=329.510..329.510 rows=756518 loops=1) Index Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Buffers: shared read=2045 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1716.798..1716.798 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=78 read=40444 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..929.781 rows=2000000 loops=1) Buffers: shared hit=78 read=40444 Planning time: 3.265 ms Execution time: 7963.767 ms (19 rows) COMMIT; COMMIT