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 '1994-06-01' and l_shipdate < cast(date '1994-06-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1174533.20..1174533.22 rows=1 width=29) (actual time=42280.526..42280.527 rows=1 loops=1) Buffers: shared hit=118707 read=331753 written=11496 -> Hash Join (cost=101750.37..1161104.23 rows=767370 width=29) (actual time=5457.495..41486.896 rows=748332 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=118707 read=331753 written=11496 -> Bitmap Heap Scan on lineitem (cost=16228.37..1058316.40 rows=767370 width=12) (actual time=971.597..33648.050 rows=748332 loops=1) Recheck Cond: ((l_shipdate >= '1994-06-01'::date) AND (l_shipdate < '1994-07-01'::date)) Buffers: shared hit=107904 read=302031 written=8164 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16036.53 rows=767370 width=0) (actual time=694.198..694.198 rows=754047 loops=1) Index Cond: ((l_shipdate >= '1994-06-01'::date) AND (l_shipdate < '1994-07-01'::date)) Buffers: shared hit=266 read=1783 written=163 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=4484.087..4484.087 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=10800 read=29722 written=3332 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..3251.229 rows=2000000 loops=1) Buffers: shared hit=10800 read=29722 written=3332 Total runtime: 42297.056 ms (17 rows) COMMIT; COMMIT