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-04-01' and l_shipdate < cast(date '1993-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1163311.45..1163311.46 rows=1 width=29) (actual time=7662.102..7662.102 rows=1 loops=1) Buffers: shared hit=196120 read=254463 written=297 -> Hash Join (cost=101523.64..1150067.66 rows=756788 width=29) (actual time=2189.526..7272.772 rows=749776 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=196120 read=254463 written=297 -> Bitmap Heap Scan on lineitem (cost=16001.64..1053193.84 rows=756788 width=12) (actual time=675.514..4943.239 rows=749776 loops=1) Recheck Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Heap Blocks: exact=408007 Buffers: shared hit=157978 read=252080 written=295 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15812.45 rows=756788 width=0) (actual time=441.825..441.825 rows=754251 loops=1) Index Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Buffers: shared hit=3 read=2048 written=6 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1501.827..1501.827 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=38139 read=2383 written=2 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..693.009 rows=2000000 loops=1) Buffers: shared hit=38139 read=2383 written=2 Planning time: 3.259 ms Execution time: 7665.006 ms (19 rows) COMMIT; COMMIT