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 '1996-01-01' and l_shipdate < cast(date '1996-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1181392.71..1181392.72 rows=1 width=29) (actual time=19848.950..19848.950 rows=1 loops=1) Buffers: shared hit=79845 read=374741 dirtied=45 written=13826 -> Hash Join (cost=102343.36..1167518.15 rows=792832 width=29) (actual time=3936.841..19187.319 rows=771844 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=79845 read=374741 dirtied=45 written=13826 -> Bitmap Heap Scan on lineitem (cost=16821.36..1064157.43 rows=792832 width=12) (actual time=1212.103..12642.265 rows=771844 loops=1) Recheck Cond: ((l_shipdate >= '1996-01-01'::date) AND (l_shipdate < '1996-02-01'::date)) Buffers: shared hit=39324 read=374737 dirtied=45 written=13826 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16623.15 rows=792832 width=0) (actual time=935.200..935.200 rows=772620 loops=1) Index Cond: ((l_shipdate >= '1996-01-01'::date) AND (l_shipdate < '1996-02-01'::date)) Buffers: shared hit=2 read=2112 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2722.940..2722.940 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=40518 read=4 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.020..931.071 rows=2000000 loops=1) Buffers: shared hit=40518 read=4 Total runtime: 19879.857 ms (17 rows) COMMIT; COMMIT