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#45' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 6 and l_quantity <= 6+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#15' 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#55' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 25 and l_quantity <= 25+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=161689.70..161689.71 rows=1 width=8) (actual time=1953.601..1953.601 rows=1 loops=1) Buffers: shared hit=35986 read=35996 dirtied=21 -> Nested Loop (cost=13396.92..161681.13 rows=1143 width=8) (actual time=286.176..1951.005 rows=1109 loops=1) Buffers: shared hit=35986 read=35996 dirtied=21 -> Bitmap Heap Scan on part (cost=13396.36..37606.54 rows=4811 width=30) (actual time=285.087..646.042 rows=4848 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#45'::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#15'::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#55'::bpchar))) Filter: ((p_size >= 1) AND (((p_brand = 'Brand#45'::bpchar) AND (p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_size <= 5)) OR ((p_brand = 'Brand#15'::bpchar) AND (p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_size <= 10)) OR ((p_brand = 'Brand#55'::bpchar) AND (p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_size <= 15)))) Rows Removed by Filter: 5526 Heap Blocks: exact=9130 Buffers: shared hit=2185 read=8768 -> BitmapOr (cost=13396.36..13396.36 rows=10458 width=0) (actual time=282.433..282.433 rows=0 loops=1) Buffers: shared hit=780 read=1043 -> BitmapAnd (cost=4466.55..4466.55 rows=808 width=0) (actual time=129.096..129.096 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.99 rows=8129 width=0) (actual time=5.511..5.511 rows=7986 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#45'::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=117.843..117.843 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8638.13..8638.13 rows=1599 width=0) (actual time=147.441..147.441 rows=0 loops=1) Buffers: shared hit=772 read=383 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.11 rows=8040 width=0) (actual time=7.254..7.254 rows=8159 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#15'::bpchar)) Buffers: shared hit=4 read=57 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8345.36 rows=397693 width=0) (actual time=134.632..134.632 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=768 read=326 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.23 rows=8051 width=0) (actual time=5.314..5.314 rows=7979 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#55'::bpchar)) Buffers: shared hit=5 read=55 -> 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.237..0.262 rows=0 loops=4848) 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 >= 6::double precision) AND (l_quantity <= 16::double precision)) OR ((l_quantity >= 10::double precision) AND (l_quantity <= 20::double precision)) OR ((l_quantity >= 25::double precision) AND (l_quantity <= 35::double precision))) AND (((part.p_brand = 'Brand#45'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 6::double precision) AND (l_quantity <= 16::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#15'::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#55'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 25::double precision) AND (l_quantity <= 35::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=33801 read=27228 dirtied=21 Planning time: 6.863 ms Execution time: 1954.269 ms (38 rows) COMMIT; COMMIT