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#52' 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#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#43' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 24 and l_quantity <= 24+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=161594.68..161594.69 rows=1 width=8) (actual time=704.809..704.809 rows=1 loops=1) Buffers: shared hit=46788 read=23558 dirtied=129 -> Nested Loop (cost=13405.08..161586.18 rows=1134 width=8) (actual time=131.264..703.964 rows=1113 loops=1) Buffers: shared hit=46788 read=23558 dirtied=129 -> Bitmap Heap Scan on part (cost=13404.51..37555.64 rows=4809 width=30) (actual time=129.596..288.803 rows=4705 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#52'::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#43'::bpchar))) Filter: ((p_size >= 1) AND (((p_brand = 'Brand#52'::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#43'::bpchar) AND (p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_size <= 15)))) Rows Removed by Filter: 5560 Heap Blocks: exact=9062 Buffers: shared hit=1312 read=9573 -> BitmapOr (cost=13404.51..13404.51 rows=10418 width=0) (actual time=127.879..127.879 rows=0 loops=1) Buffers: shared hit=559 read=1264 -> BitmapAnd (cost=4455.92..4455.92 rows=795 width=0) (actual time=49.365..49.365 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..289.91 rows=8020 width=0) (actual time=3.805..3.805 rows=8026 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#52'::bpchar)) Buffers: shared hit=3 read=57 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4163.36 rows=198293 width=0) (actual time=43.629..43.629 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8657.38..8657.38 rows=1617 width=0) (actual time=74.944..74.944 rows=0 loops=1) Buffers: shared hit=552 read=603 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.83 rows=8110 width=0) (actual time=3.450..3.450 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..8363.90 rows=398747 width=0) (actual time=69.590..69.590 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.75 rows=8006 width=0) (actual time=3.277..3.277 rows=7912 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#43'::bpchar)) Buffers: shared hit=4 read=56 -> 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.077..0.085 rows=0 loops=4705) 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 >= 10::double precision) AND (l_quantity <= 20::double precision)) OR ((l_quantity >= 24::double precision) AND (l_quantity <= 34::double precision))) AND (((part.p_brand = 'Brand#52'::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#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#43'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 24::double precision) AND (l_quantity <= 34::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=45476 read=13985 dirtied=129 Planning time: 4.514 ms Execution time: 705.200 ms (38 rows) COMMIT; COMMIT