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#44' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 5 and l_quantity <= 5+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#55' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 14 and l_quantity <= 14+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#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 23 and l_quantity <= 23+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=613949.39..613949.40 rows=1 width=8) (actual time=1553.623..1553.623 rows=1 loops=1) Buffers: shared hit=116364 read=65070 dirtied=1068 written=9 -> Nested Loop (cost=12891.10..613940.80 rows=1145 width=8) (actual time=35.051..1552.710 rows=1179 loops=1) Buffers: shared hit=116364 read=65070 dirtied=1068 written=9 -> Bitmap Heap Scan on part (cost=12890.54..26606.98 rows=4767 width=30) (actual time=33.435..274.949 rows=4750 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#44'::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#55'::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#34'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Rows Removed by Index Recheck: 18826 Heap Blocks: exact=18082 Buffers: shared hit=1684 read=16582 written=3 -> BitmapOr (cost=12890.54..12890.54 rows=4770 width=0) (actual time=29.585..29.585 rows=0 loops=1) Buffers: shared hit=16 read=168 -> BitmapAnd (cost=2305.69..2305.69 rows=801 width=0) (actual time=8.762..8.762 rows=0 loops=1) Buffers: shared hit=4 read=58 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.79 rows=8008 width=0) (actual time=3.782..3.782 rows=7865 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#44'::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.203..4.203 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared hit=1 read=1 -> BitmapAnd (cost=4297.29..4297.29 rows=1587 width=0) (actual time=8.653..8.653 rows=0 loops=1) Buffers: shared hit=6 read=55 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.19 rows=7947 width=0) (actual time=3.691..3.691 rows=7853 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#55'::bpchar)) Buffers: shared hit=4 read=55 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.187..4.187 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6287.05..6287.05 rows=2382 width=0) (actual time=8.331..8.331 rows=0 loops=1) Buffers: shared hit=6 read=55 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.35 rows=7964 width=0) (actual time=3.412..3.412 rows=7858 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#34'::bpchar)) Buffers: shared hit=4 read=55 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..5995.07 rows=598307 width=0) (actual time=4.192..4.192 rows=405760 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=2 -> Index Scan using lineitem_l_partkey_l_quantity_idx on lineitem (cost=0.56..123.20 rows=1 width=16) (actual time=0.236..0.267 rows=0 loops=4750) 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 >= 5::double precision) AND (l_quantity <= 15::double precision)) OR ((l_quantity >= 14::double precision) AND (l_quantity <= 24::double precision)) OR ((l_quantity >= 23::double precision) AND (l_quantity <= 33::double precision))) AND (((part.p_brand = 'Brand#44'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 5::double precision) AND (l_quantity <= 15::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#55'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 14::double precision) AND (l_quantity <= 24::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#34'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 23::double precision) AND (l_quantity <= 33::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 30 Buffers: shared hit=114680 read=48488 dirtied=1068 written=6 Planning time: 3.574 ms Execution time: 1553.993 ms (42 rows) COMMIT; COMMIT