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-10-01' and l_shipdate < cast(date '1994-10-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1172348.09..1172348.11 rows=1 width=29) (actual time=7635.277..7635.278 rows=1 loops=1) Buffers: shared hit=243268 read=212066 dirtied=421 written=8814 -> Hash Join (cost=102110.65..1158648.43 rows=782838 width=29) (actual time=2550.218..7265.124 rows=771049 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=243268 read=212066 dirtied=421 written=8814 -> Bitmap Heap Scan on lineitem (cost=16588.65..1061383.86 rows=782838 width=12) (actual time=1196.026..5193.048 rows=771049 loops=1) Recheck Cond: ((l_shipdate >= '1994-10-01'::date) AND (l_shipdate < '1994-11-01'::date)) Heap Blocks: exact=412698 Buffers: shared hit=202743 read=212066 dirtied=421 written=8814 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16392.94 rows=782838 width=0) (actual time=1033.751..1033.751 rows=773270 loops=1) Index Cond: ((l_shipdate >= '1994-10-01'::date) AND (l_shipdate < '1994-11-01'::date)) Buffers: shared hit=390 read=1721 written=144 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1343.827..1343.827 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40522 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..676.749 rows=2000000 loops=1) Buffers: shared hit=40522 Planning time: 2.410 ms Execution time: 7641.510 ms (19 rows) COMMIT; COMMIT