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=1179613.91..1179613.92 rows=1 width=29) (actual time=11264.931..11264.931 rows=1 loops=1) Buffers: shared hit=95889 read=357964 written=7027 -> Hash Join (cost=102544.84..1165569.05 rows=802563 width=29) (actual time=2338.707..10793.821 rows=771322 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=95889 read=357964 written=7027 -> Bitmap Heap Scan on lineitem (cost=17022.84..1068008.61 rows=802563 width=12) (actual time=781.761..7789.637 rows=771322 loops=1) Recheck Cond: ((l_shipdate >= '1995-12-01'::date) AND (l_shipdate < '1996-01-01'::date)) Heap Blocks: exact=411216 Buffers: shared hit=55368 read=357960 written=7027 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16822.19 rows=802563 width=0) (actual time=574.235..574.235 rows=772110 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=1549.130..1549.130 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40518 read=4 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.022..743.553 rows=2000000 loops=1) Buffers: shared hit=40518 read=4 Planning time: 2.970 ms Execution time: 11269.827 ms (19 rows) COMMIT; COMMIT