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#41' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1+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#33' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 15 and l_quantity <= 15+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#23' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 30 and l_quantity <= 30+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=614185.88..614185.89 rows=1 width=8) (actual time=2158.742..2158.742 rows=1 loops=1) Buffers: shared hit=96132 read=84675 dirtied=807 written=14728 -> Nested Loop (cost=12875.79..614177.28 rows=1146 width=8) (actual time=34.214..2157.648 rows=1230 loops=1) Buffers: shared hit=96132 read=84675 dirtied=807 written=14728 -> Bitmap Heap Scan on part (cost=12875.22..26601.84 rows=4770 width=30) (actual time=33.638..353.440 rows=4749 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#41'::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#33'::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#23'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Rows Removed by Index Recheck: 19323 Heap Blocks: exact=18181 Buffers: shared hit=16 read=18353 written=3237 -> BitmapOr (cost=12875.22..12875.22 rows=4774 width=0) (actual time=29.792..29.792 rows=0 loops=1) Buffers: shared hit=15 read=173 -> BitmapAnd (cost=2305.93..2305.93 rows=804 width=0) (actual time=8.735..8.735 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..290.03 rows=8033 width=0) (actual time=3.717..3.717 rows=8055 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#41'::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.206..4.206 rows=405760 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=2 -> BitmapAnd (cost=4298.57..4298.57 rows=1612 width=0) (actual time=8.727..8.727 rows=0 loops=1) Buffers: shared hit=6 read=57 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.47 rows=8075 width=0) (actual time=3.741..3.741 rows=8090 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#33'::bpchar)) Buffers: shared hit=4 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..4005.47 rows=399347 width=0) (actual time=4.176..4.176 rows=405760 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=2 -> BitmapAnd (cost=6270.21..6270.21 rows=2357 width=0) (actual time=8.462..8.462 rows=0 loops=1) Buffers: shared hit=6 read=57 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..272.51 rows=7880 width=0) (actual time=3.486..3.486 rows=7927 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#23'::bpchar)) Buffers: shared hit=4 read=57 -> Bitmap Index Scan on part_p_size_brin_idx (cost=0.00..5995.07 rows=598307 width=0) (actual time=4.181..4.181 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.17 rows=1 width=16) (actual time=0.335..0.378 rows=0 loops=4749) 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 >= 1::double precision) AND (l_quantity <= 11::double precision)) OR ((l_quantity >= 15::double precision) AND (l_quantity <= 25::double precision)) OR ((l_quantity >= 30::double precision) AND (l_quantity <= 40::double precision))) AND (((part.p_brand = 'Brand#41'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 1::double precision) AND (l_quantity <= 11::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#33'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 15::double precision) AND (l_quantity <= 25::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#23'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 30::double precision) AND (l_quantity <= 40::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 30 Buffers: shared hit=96116 read=66322 dirtied=807 written=11491 Planning time: 115.023 ms Execution time: 2159.131 ms (42 rows) COMMIT; COMMIT