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#31' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 4 and l_quantity <= 4+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#13' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 10 and l_quantity <= 10+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 >= 27 and l_quantity <= 27+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=613532.09..613532.10 rows=1 width=8) (actual time=1626.945..1626.945 rows=1 loops=1) Buffers: shared hit=134658 read=52135 -> Nested Loop (cost=12896.30..613523.57 rows=1136 width=8) (actual time=33.742..1626.088 rows=1141 loops=1) Buffers: shared hit=134658 read=52135 -> Bitmap Heap Scan on part (cost=12891.56..26648.70 rows=4783 width=30) (actual time=33.340..292.526 rows=4925 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#31'::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#13'::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: 19136 Heap Blocks: exact=18216 Buffers: shared hit=41 read=18361 -> BitmapOr (cost=12891.56..12891.56 rows=4787 width=0) (actual time=29.364..29.364 rows=0 loops=1) Buffers: shared hit=17 read=169 -> BitmapAnd (cost=2305.82..2305.82 rows=802 width=0) (actual time=8.650..8.650 rows=0 loops=1) Buffers: shared hit=5 read=57 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.91 rows=8019 width=0) (actual time=3.744..3.744 rows=7903 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#31'::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.179..4.179 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=4298.46..4298.46 rows=1610 width=0) (actual time=8.552..8.552 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..290.35 rows=8062 width=0) (actual time=3.650..3.650 rows=8004 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#13'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.170..4.170 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6286.78..6286.78 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.480..3.480 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.168..4.168 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.243..0.265 rows=0 loops=4925) 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 >= 4::double precision) AND (l_quantity <= 14::double precision)) OR ((l_quantity >= 10::double precision) AND (l_quantity <= 20::double precision)) OR ((l_quantity >= 27::double precision) AND (l_quantity <= 37::double precision))) AND (((part.p_brand = 'Brand#31'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 4::double precision) AND (l_quantity <= 14::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#13'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 10::double precision) AND (l_quantity <= 20::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 >= 27::double precision) AND (l_quantity <= 37::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 30 Heap Blocks: exact=148278 Buffers: shared hit=134617 read=33774 -> Bitmap Index Scan on lineitem_l_partkey_l_quantity_idx (cost=0.00..4.74 rows=31 width=0) (actual time=0.027..0.027 rows=30 loops=4925) Index Cond: (l_partkey = part.p_partkey) Buffers: shared hit=14872 read=5241 Planning time: 3.277 ms Execution time: 1627.299 ms (46 rows) COMMIT; COMMIT