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 '1997-09-01' and l_shipdate < cast(date '1997-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1162403.62..1162403.64 rows=1 width=29) (actual time=9320.831..9320.831 rows=1 loops=1) Buffers: shared hit=236161 read=216094 written=2411 -> Hash Join (cost=101101.53..1149488.27 rows=738020 width=29) (actual time=2059.264..8944.611 rows=749135 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=236161 read=216094 written=2411 -> Bitmap Heap Scan on lineitem (cost=15579.53..1047360.82 rows=738020 width=12) (actual time=501.929..4966.601 rows=749135 loops=1) Recheck Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared hit=206779 read=204951 written=2334 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15395.03 rows=738020 width=0) (actual time=345.533..345.533 rows=756696 loops=1) Index Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared hit=3 read=2047 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1555.446..1555.446 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=29379 read=11143 written=77 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..791.080 rows=2000000 loops=1) Buffers: shared hit=29379 read=11143 written=77 Total runtime: 9332.638 ms (17 rows) COMMIT; COMMIT