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-01-01' and l_shipdate < cast(date '1997-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1176521.15..1176521.17 rows=1 width=29) (actual time=7253.525..7253.526 rows=1 loops=1) Buffers: shared hit=967 read=453571 -> Hash Join (cost=102390.70..1162602.88 rows=795330 width=29) (actual time=1804.675..6861.890 rows=773251 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=967 read=453571 -> Bitmap Heap Scan on lineitem (cost=16868.70..1065150.93 rows=795330 width=12) (actual time=397.927..4784.617 rows=773251 loops=1) Recheck Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Heap Blocks: exact=411898 Buffers: shared hit=962 read=413051 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16669.86 rows=795330 width=0) (actual time=248.547..248.547 rows=773251 loops=1) Index Cond: ((l_shipdate >= '1997-01-01'::date) AND (l_shipdate < '1997-02-01'::date)) Buffers: shared hit=592 read=1523 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1399.359..1399.359 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2 read=40520 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..759.399 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 Planning time: 4.187 ms Execution time: 7256.444 ms (19 rows) COMMIT; COMMIT