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-10-01' and l_shipdate < cast(date '1995-10-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1183001.34..1183001.35 rows=1 width=29) (actual time=19438.794..19438.794 rows=1 loops=1) Buffers: shared hit=197653 read=261441 written=209 -> Hash Join (cost=101994.91..1169346.07 rows=780301 width=29) (actual time=4438.739..18747.607 rows=774201 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=197653 read=261441 written=209 -> Bitmap Heap Scan on lineitem (cost=16472.91..1066267.30 rows=780301 width=12) (actual time=1021.739..11688.095 rows=774201 loops=1) Recheck Cond: ((l_shipdate >= '1995-10-01'::date) AND (l_shipdate < '1995-11-01'::date)) Buffers: shared hit=181962 read=236607 written=209 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16277.84 rows=780301 width=0) (actual time=734.300..734.300 rows=781910 loops=1) Index Cond: ((l_shipdate >= '1995-10-01'::date) AND (l_shipdate < '1995-11-01'::date)) Buffers: shared read=2119 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=3414.850..3414.850 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=15688 read=24834 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..1683.787 rows=2000000 loops=1) Buffers: shared hit=15688 read=24834 Total runtime: 19464.349 ms (17 rows) COMMIT; COMMIT