BEGIN; BEGIN EXPLAIN select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#53' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 6 and l_quantity <= 6+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#32' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 18 and l_quantity <= 18+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#11' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 29 and l_quantity <= 29+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=607139.74..607139.75 rows=1 width=8) -> Nested Loop (cost=12873.42..607131.32 rows=1123 width=8) -> Bitmap Heap Scan on part (cost=12872.86..26466.84 rows=4713 width=30) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#53'::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#32'::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#11'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) -> BitmapOr (cost=12872.86..12872.86 rows=4716 width=0) -> BitmapAnd (cost=2305.75..2305.75 rows=802 width=0) -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.87 rows=8016 width=0) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#53'::bpchar)) -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..2013.27 rows=200127 width=0) Index Cond: ((p_size <= 5) AND (p_size >= 1)) -> BitmapAnd (cost=4297.75..4297.75 rows=1596 width=0) -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.67 rows=7995 width=0) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#32'::bpchar)) -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) Index Cond: ((p_size <= 10) AND (p_size >= 1)) -> BitmapAnd (cost=6268.87..6268.87 rows=2317 width=0) -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..271.19 rows=7747 width=0) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#11'::bpchar)) -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..5995.07 rows=598307 width=0) Index Cond: ((p_size <= 15) AND (p_size >= 1)) -> Index Scan using lineitem_l_partkey_l_quantity_idx on lineitem (cost=0.56..123.19 rows=1 width=16) Index Cond: (l_partkey = part.p_partkey) Filter: ((l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[])) AND (l_shipinstruct = 'DELIVER IN PERSON'::bpchar) AND (((l_quantity >= 6::double precision) AND (l_quantity <= 16::double precision)) OR ((l_quantity >= 18::double precision) AND (l_quantity <= 28::double precision)) OR ((l_quantity >= 29::double precision) AND (l_quantity <= 39::double precision))) AND (((part.p_brand = 'Brand#53'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 6::double precision) AND (l_quantity <= 16::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#32'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 18::double precision) AND (l_quantity <= 28::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#11'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 29::double precision) AND (l_quantity <= 39::double precision) AND (part.p_size <= 15)))) Planning time: 3.152 ms (24 rows) COMMIT; COMMIT