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-03-01' and l_shipdate < cast(date '1996-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170143.40..1170143.41 rows=1 width=29) (actual time=14557.520..14557.520 rows=1 loops=1) Buffers: shared hit=145042 read=314182 -> Hash Join (cost=101350.51..1157007.84 rows=750603 width=29) (actual time=3552.088..13948.359 rows=772419 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=145042 read=314182 -> Bitmap Heap Scan on lineitem (cost=15828.51..1054597.28 rows=750603 width=12) (actual time=748.807..7724.509 rows=772419 loops=1) Recheck Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Buffers: shared hit=137238 read=281461 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15640.86 rows=750603 width=0) (actual time=552.397..552.397 rows=781882 loops=1) Index Cond: ((l_shipdate >= '1996-03-01'::date) AND (l_shipdate < '1996-04-01'::date)) Buffers: shared read=2114 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2801.275..2801.275 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=7801 read=32721 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.016..1425.942 rows=2000000 loops=1) Buffers: shared hit=7801 read=32721 Total runtime: 14581.301 ms (17 rows) COMMIT; COMMIT