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#33' 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#42' 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#12' 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=164299.06..164299.07 rows=1 width=8) (actual time=1048.839..1048.839 rows=1 loops=1) Buffers: shared hit=47709 read=19868 dirtied=84 written=20 -> Nested Loop (cost=25943.11..164290.35 rows=1161 width=8) (actual time=477.233..1047.866 rows=1175 loops=1) Buffers: shared hit=47709 read=19868 dirtied=84 written=20 -> Bitmap Heap Scan on part (cost=25942.54..39798.80 rows=4827 width=30) (actual time=476.244..567.887 rows=4712 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#33'::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#42'::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#12'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4436 Buffers: shared hit=2146 read=5749 written=7 -> BitmapOr (cost=25942.54..25942.54 rows=4831 width=0) (actual time=475.082..475.082 rows=0 loops=1) Buffers: shared hit=1653 read=1806 written=1 -> BitmapAnd (cost=4466.15..4466.15 rows=804 width=0) (actual time=84.648..84.648 rows=0 loops=1) Buffers: shared hit=3 read=605 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.59 rows=8087 width=0) (actual time=5.941..5.941 rows=7925 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#33'::bpchar)) Buffers: shared hit=3 read=57 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4172.90 rows=198847 width=0) (actual time=75.427..75.427 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8637.73..8637.73 rows=1591 width=0) (actual time=203.305..203.305 rows=0 loops=1) Buffers: shared hit=552 read=602 written=1 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.71 rows=8001 width=0) (actual time=5.466..5.466 rows=7938 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#42'::bpchar)) Buffers: shared hit=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8345.36 rows=397693 width=0) (actual time=191.292..191.292 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 written=1 -> BitmapAnd (cost=12838.15..12838.15 rows=2436 width=0) (actual time=185.163..185.163 rows=0 loops=1) Buffers: shared hit=1098 read=599 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..291.19 rows=8147 width=0) (actual time=5.093..5.093 rows=8175 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#12'::bpchar)) Buffers: shared hit=4 read=55 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12544.30 rows=597987 width=0) (actual time=176.665..176.665 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.089..0.099 rows=0 loops=4712) 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 >= 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#33'::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#42'::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#12'::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: 4 Buffers: shared hit=45563 read=14119 dirtied=84 written=13 Planning time: 7.583 ms Execution time: 1049.489 ms (41 rows) COMMIT; COMMIT