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-02-01' and l_shipdate < cast(date '1995-02-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1161121.10..1161121.11 rows=1 width=29) (actual time=8483.035..8483.036 rows=1 loops=1) Buffers: shared hit=218577 read=218946 written=245 -> Hash Join (cost=101202.08..1148105.33 rows=743758 width=29) (actual time=2353.938..8070.847 rows=698188 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=218577 read=218946 written=245 -> Bitmap Heap Scan on lineitem (cost=15680.08..1051426.96 rows=743758 width=12) (actual time=468.406..5205.902 rows=698188 loops=1) Recheck Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Heap Blocks: exact=395088 Buffers: shared hit=214960 read=182038 written=204 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15494.15 rows=743758 width=0) (actual time=316.657..316.657 rows=706623 loops=1) Index Cond: ((l_shipdate >= '1995-02-01'::date) AND (l_shipdate < '1995-03-01'::date)) Buffers: shared read=1910 written=2 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1877.349..1877.349 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=3614 read=36908 written=41 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.017..1153.452 rows=2000000 loops=1) Buffers: shared hit=3614 read=36908 written=41 Planning time: 3.155 ms Execution time: 8487.391 ms (19 rows) COMMIT; COMMIT