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-09-01' and l_shipdate < cast(date '1995-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1175238.59..1175238.60 rows=1 width=29) (actual time=7224.578..7224.578 rows=1 loops=1) Buffers: shared hit=259246 read=194266 written=126 -> Hash Join (cost=101818.26..1161710.34 rows=773043 width=29) (actual time=2183.133..6856.739 rows=749792 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=259246 read=194266 written=126 -> Bitmap Heap Scan on lineitem (cost=16296.26..1064592.69 rows=773043 width=12) (actual time=497.291..4482.831 rows=749792 loops=1) Recheck Cond: ((l_shipdate >= '1995-09-01'::date) AND (l_shipdate < '1995-10-01'::date)) Heap Blocks: exact=410936 Buffers: shared hit=254239 read=158748 written=86 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16103.00 rows=773043 width=0) (actual time=340.291..340.291 rows=758914 loops=1) Index Cond: ((l_shipdate >= '1995-09-01'::date) AND (l_shipdate < '1995-10-01'::date)) Buffers: shared read=2051 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1675.422..1675.422 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=5004 read=35518 written=40 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..1016.467 rows=2000000 loops=1) Buffers: shared hit=5004 read=35518 written=40 Planning time: 3.336 ms Execution time: 7227.074 ms (19 rows) COMMIT; COMMIT