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#54' 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#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 17 and l_quantity <= 17+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#44' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 28 and l_quantity <= 28+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=166009.77..166009.78 rows=1 width=8) (actual time=854.313..854.313 rows=1 loops=1) Buffers: shared hit=34349 read=33276 dirtied=27 -> Nested Loop (cost=26051.62..166001.11 rows=1155 width=8) (actual time=260.111..853.461 rows=1110 loops=1) Buffers: shared hit=34349 read=33276 dirtied=27 -> Bitmap Heap Scan on part (cost=26051.06..40034.06 rows=4885 width=30) (actual time=259.559..335.996 rows=4756 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#54'::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#23'::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#44'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4514 Buffers: shared hit=1653 read=6318 -> BitmapOr (cost=26051.06..26051.06 rows=4888 width=0) (actual time=258.626..258.626 rows=0 loops=1) Buffers: shared hit=1653 read=1804 -> BitmapAnd (cost=4489.46..4489.46 rows=800 width=0) (actual time=52.413..52.413 rows=0 loops=1) Buffers: shared hit=3 read=604 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.67 rows=7998 width=0) (actual time=3.740..3.740 rows=7886 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#54'::bpchar)) Buffers: shared hit=3 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4197.10 rows=200067 width=0) (actual time=46.461..46.461 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8685.11..8685.11 rows=1609 width=0) (actual time=85.749..85.749 rows=0 loops=1) Buffers: shared hit=552 read=601 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.19 rows=8047 width=0) (actual time=3.653..3.653 rows=8018 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#23'::bpchar)) Buffers: shared hit=4 read=55 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8392.23 rows=399980 width=0) (actual time=79.801..79.801 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 -> BitmapAnd (cost=12875.98..12875.98 rows=2479 width=0) (actual time=119.707..119.707 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..292.39 rows=8268 width=0) (actual time=3.272..3.272 rows=7932 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#44'::bpchar)) Buffers: shared hit=4 read=55 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12580.90 rows=599647 width=0) (actual time=114.126..114.126 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.096..0.105 rows=0 loops=4756) 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 >= 1::double precision) AND (l_quantity <= 11::double precision)) OR ((l_quantity >= 17::double precision) AND (l_quantity <= 27::double precision)) OR ((l_quantity >= 28::double precision) AND (l_quantity <= 38::double precision))) AND (((part.p_brand = 'Brand#54'::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#23'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 17::double precision) AND (l_quantity <= 27::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#44'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 28::double precision) AND (l_quantity <= 38::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=32696 read=26958 dirtied=27 Planning time: 3.675 ms Execution time: 854.664 ms (41 rows) COMMIT; COMMIT