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 '1993-12-01' and l_shipdate < cast(date '1993-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1174162.84..1174162.86 rows=1 width=29) (actual time=10178.608..10178.608 rows=1 loops=1) Buffers: shared hit=199774 read=259137 written=262 -> Hash Join (cost=101810.37..1160648.05 rows=772274 width=29) (actual time=3111.993..9639.958 rows=772987 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=199774 read=259137 written=262 -> Bitmap Heap Scan on lineitem (cost=16288.37..1063541.94 rows=772274 width=12) (actual time=680.668..6217.617 rows=772987 loops=1) Recheck Cond: ((l_shipdate >= '1993-12-01'::date) AND (l_shipdate < '1994-01-01'::date)) Heap Blocks: exact=416273 Buffers: shared hit=186070 read=232316 written=220 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16095.31 rows=772274 width=0) (actual time=444.256..444.256 rows=781326 loops=1) Index Cond: ((l_shipdate >= '1993-12-01'::date) AND (l_shipdate < '1994-01-01'::date)) Buffers: shared read=2113 written=5 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2418.502..2418.502 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=13701 read=26821 written=42 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..1384.534 rows=2000000 loops=1) Buffers: shared hit=13701 read=26821 written=42 Planning time: 3.200 ms Execution time: 10184.937 ms (19 rows) COMMIT; COMMIT