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#23' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 3 and l_quantity <= 3+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#45' 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#35' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 21 and l_quantity <= 21+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=165750.36..165750.37 rows=1 width=8) (actual time=657.497..657.497 rows=1 loops=1) Buffers: shared hit=47045 read=20008 dirtied=188 written=4 -> Nested Loop (cost=26115.76..165741.63 rows=1164 width=8) (actual time=244.745..656.735 rows=1164 loops=1) Buffers: shared hit=47045 read=20008 dirtied=188 written=4 -> Bitmap Heap Scan on part (cost=26115.20..40075.39 rows=4873 width=30) (actual time=244.556..310.465 rows=4687 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#23'::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#45'::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#35'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4385 Buffers: shared hit=1654 read=6191 written=1 -> BitmapOr (cost=26115.20..26115.20 rows=4877 width=0) (actual time=243.646..243.646 rows=0 loops=1) Buffers: shared hit=1654 read=1806 -> BitmapAnd (cost=4471.26..4471.26 rows=792 width=0) (actual time=54.655..54.655 rows=0 loops=1) Buffers: shared hit=4 read=604 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.27 rows=7955 width=0) (actual time=3.928..3.928 rows=8005 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#23'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4179.30 rows=199087 width=0) (actual time=48.664..48.664 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8721.66..8721.66 rows=1606 width=0) (actual time=78.944..78.944 rows=0 loops=1) Buffers: shared hit=552 read=602 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.67 rows=7996 width=0) (actual time=3.583..3.583 rows=7921 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#45'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8429.30 rows=401687 width=0) (actual time=73.408..73.408 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 -> BitmapAnd (cost=12921.79..12921.79 rows=2479 width=0) (actual time=109.307..109.307 rows=0 loops=1) Buffers: shared hit=1098 read=600 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..292.07 rows=8237 width=0) (actual time=3.468..3.468 rows=8038 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#35'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12627.03 rows=601860 width=0) (actual time=103.817..103.817 rows=598661 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=1094 read=544 -> Index Scan using lineitem_l_partkey_l_quantity_l_shipmode_idx on lineitem (cost=0.56..25.78 rows=1 width=16) (actual time=0.064..0.071 rows=0 loops=4687) Index Cond: ((l_partkey = part.p_partkey) AND (l_shipmode = ANY ('{AIR,"AIR REG"}'::bpchar[]))) Filter: ((l_shipinstruct = 'DELIVER IN PERSON'::bpchar) AND (((l_quantity >= 3::double precision) AND (l_quantity <= 13::double precision)) OR ((l_quantity >= 14::double precision) AND (l_quantity <= 24::double precision)) OR ((l_quantity >= 21::double precision) AND (l_quantity <= 31::double precision))) AND (((part.p_brand = 'Brand#23'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 3::double precision) AND (l_quantity <= 13::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#45'::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#35'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 21::double precision) AND (l_quantity <= 31::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=45391 read=13817 dirtied=188 written=3 Planning time: 4.242 ms Execution time: 657.844 ms (41 rows) COMMIT; COMMIT