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=1148862.81..1148862.83 rows=1 width=29) (actual time=10410.452..10410.453 rows=1 loops=1) Buffers: shared hit=229614 read=207147 written=75 -> Hash Join (cost=100562.34..1136396.81 rows=712343 width=29) (actual time=2570.756..9935.180 rows=698999 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=229614 read=207147 written=75 -> Bitmap Heap Scan on lineitem (cost=15040.34..1034847.09 rows=712343 width=12) (actual time=645.532..5698.697 rows=698999 loops=1) Recheck Cond: ((l_shipdate >= '1994-02-01'::date) AND (l_shipdate < '1994-03-01'::date)) Buffers: shared hit=189093 read=207143 written=75 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..14862.26 rows=712343 width=0) (actual time=441.668..441.668 rows=705956 loops=1) Index Cond: ((l_shipdate >= '1994-02-01'::date) AND (l_shipdate < '1994-03-01'::date)) Buffers: shared read=1913 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1923.190..1923.190 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40518 read=4 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..1001.749 rows=2000000 loops=1) Buffers: shared hit=40518 read=4 Total runtime: 10423.895 ms (17 rows) COMMIT; COMMIT