BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#24' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 9 and l_quantity <= 9+10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#35' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 20 and l_quantity <= 20+10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#42' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 20 and l_quantity <= 20+10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=616537.52..616537.53 rows=1 width=8) (actual time=1843.431..1843.431 rows=1 loops=1) Buffers: shared hit=119586 read=67969 written=9 -> Nested Loop (cost=12897.38..616528.86 rows=1154 width=8) (actual time=34.404..1842.330 rows=1161 loops=1) Buffers: shared hit=119586 read=67969 written=9 -> Bitmap Heap Scan on part (cost=12892.64..26703.20 rows=4807 width=30) (actual time=33.197..215.025 rows=4939 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#24'::bpchar) AND (p_size <= 5) AND (p_size >= 1)) OR ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#35'::bpchar) AND (p_size <= 10) AND (p_size >= 1)) OR ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#42'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Rows Removed by Index Recheck: 19217 Heap Blocks: exact=18219 Buffers: shared hit=9493 read=8914 written=1 -> BitmapOr (cost=12892.64..12892.64 rows=4811 width=0) (actual time=29.390..29.390 rows=0 loops=1) Buffers: shared hit=15 read=173 -> BitmapAnd (cost=2305.55..2305.55 rows=800 width=0) (actual time=8.510..8.510 rows=0 loops=1) Buffers: shared hit=3 read=59 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.63 rows=7993 width=0) (actual time=3.566..3.566 rows=7816 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#24'::bpchar)) Buffers: shared hit=3 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..2013.27 rows=200127 width=0) (actual time=4.194..4.194 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=2 -> BitmapAnd (cost=4299.79..4299.79 rows=1636 width=0) (actual time=8.630..8.630 rows=0 loops=1) Buffers: shared hit=6 read=58 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..291.67 rows=8195 width=0) (actual time=3.667..3.667 rows=8186 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#35'::bpchar)) Buffers: shared hit=4 read=58 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.175..4.175 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6286.79..6286.79 rows=2374 width=0) (actual time=8.357..8.357 rows=0 loops=1) Buffers: shared hit=6 read=56 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.07 rows=7937 width=0) (actual time=3.459..3.459 rows=8154 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#42'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..5995.07 rows=598307 width=0) (actual time=4.171..4.171 rows=405760 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=2 -> Bitmap Heap Scan on lineitem (cost=4.74..122.69 rows=1 width=16) (actual time=0.295..0.324 rows=0 loops=4939) Recheck Cond: (l_partkey = part.p_partkey) Filter: ((l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[])) AND (l_shipinstruct = 'DELIVER IN PERSON'::bpchar) AND (((l_quantity >= 9::double precision) AND (l_quantity <= 19::double precision)) OR ((l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision)) OR ((l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision))) AND (((part.p_brand = 'Brand#24'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 9::double precision) AND (l_quantity <= 19::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#35'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#42'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 20::double precision) AND (l_quantity <= 30::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 30 Heap Blocks: exact=148973 Buffers: shared hit=110093 read=59055 written=8 -> Bitmap Index Scan on lineitem_l_partkey_l_quantity_idx (cost=0.00..4.74 rows=31 width=0) (actual time=0.026..0.026 rows=30 loops=4939) Index Cond: (l_partkey = part.p_partkey) Buffers: shared hit=15195 read=4980 written=2 Planning time: 3.523 ms Execution time: 1843.835 ms (46 rows) COMMIT; COMMIT