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-12-01' and l_shipdate < cast(date '1995-12-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1172076.46..1172076.48 rows=1 width=29) (actual time=14986.098..14986.098 rows=1 loops=1) Buffers: shared hit=243235 read=213066 written=220 -> Hash Join (cost=101919.55..1158505.02 rows=775511 width=29) (actual time=9085.827..14591.963 rows=771980 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=243235 read=213066 written=220 -> Bitmap Heap Scan on lineitem (cost=16397.55..1061350.36 rows=775511 width=12) (actual time=7474.212..12221.553 rows=771980 loops=1) Recheck Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Heap Blocks: exact=413664 Buffers: shared hit=205657 read=210119 written=220 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16203.68 rows=775511 width=0) (actual time=7009.617..7009.617 rows=776674 loops=1) Index Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Buffers: shared read=2112 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1594.761..1594.761 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=37575 read=2947 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.045..851.028 rows=2000000 loops=1) Buffers: shared hit=37575 read=2947 Planning time: 2.777 ms Execution time: 14994.008 ms (19 rows) COMMIT; COMMIT