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 '1995-02-01' and l_shipdate < cast(date '1995-02-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1146382.89..1146382.90 rows=1 width=29) (actual time=9356.604..9356.604 rows=1 loops=1) Buffers: shared hit=192055 read=241936 dirtied=326 written=94 -> Hash Join (cost=100911.97..1133664.39 rows=726771 width=29) (actual time=4440.262..8985.669 rows=698204 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=192055 read=241936 dirtied=326 written=94 -> Bitmap Heap Scan on lineitem (cost=15389.97..1037240.83 rows=726771 width=12) (actual time=2843.894..6707.427 rows=698204 loops=1) Recheck Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Heap Blocks: exact=391556 Buffers: shared hit=181554 read=211912 dirtied=326 written=94 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15208.27 rows=726771 width=0) (actual time=2651.422..2651.422 rows=700269 loops=1) Index Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Buffers: shared hit=2 read=1908 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1584.139..1584.139 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=10498 read=30024 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..879.077 rows=2000000 loops=1) Buffers: shared hit=10498 read=30024 Planning time: 3.083 ms Execution time: 9363.458 ms (19 rows) COMMIT; COMMIT