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-07-01' and l_shipdate < cast(date '1995-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1185888.26..1185888.28 rows=1 width=29) (actual time=8830.150..8830.150 rows=1 loops=1) Buffers: shared hit=227113 read=231623 written=104 -> Hash Join (cost=102447.63..1171859.13 rows=801665 width=29) (actual time=3195.856..8438.238 rows=773707 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=227113 read=231623 written=104 -> Bitmap Heap Scan on lineitem (cost=16925.63..1074312.15 rows=801665 width=12) (actual time=1255.272..5776.002 rows=773707 loops=1) Recheck Cond: ((l_shipdate >= '1995-07-01'::date) AND (l_shipdate < '1995-08-01'::date)) Heap Blocks: exact=416095 Buffers: shared hit=225089 read=193122 written=78 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16725.22 rows=801665 width=0) (actual time=960.902..960.902 rows=780709 loops=1) Index Cond: ((l_shipdate >= '1995-07-01'::date) AND (l_shipdate < '1995-08-01'::date)) Buffers: shared read=2116 written=3 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1714.969..1714.969 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2021 read=38501 written=26 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.031..1013.524 rows=2000000 loops=1) Buffers: shared hit=2021 read=38501 written=26 Planning time: 4.748 ms Execution time: 8838.735 ms (19 rows) COMMIT; COMMIT