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 >= 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#35' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 16 and l_quantity <= 16+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 >= 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=162046.73..162046.74 rows=1 width=8) (actual time=584.560..584.560 rows=1 loops=1) Buffers: shared hit=54216 read=18002 dirtied=145 -> Nested Loop (cost=13467.65..162038.12 rows=1149 width=8) (actual time=139.954..583.844 rows=1154 loops=1) Buffers: shared hit=54216 read=18002 dirtied=145 -> Bitmap Heap Scan on part (cost=13467.08..37646.79 rows=4823 width=30) (actual time=139.580..259.464 rows=4867 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#35'::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#52'::bpchar) AND (p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_size <= 5)) OR ((p_brand = 'Brand#35'::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=9196 Buffers: shared hit=4078 read=6942 -> BitmapOr (cost=13467.08..13467.08 rows=10437 width=0) (actual time=137.804..137.804 rows=0 loops=1) Buffers: shared hit=1658 read=166 -> BitmapAnd (cost=4490.47..4490.47 rows=810 width=0) (actual time=41.567..41.567 rows=0 loops=1) Buffers: shared hit=554 read=54 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.71 rows=8099 width=0) (actual time=3.744..3.744 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=6 read=54 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4197.10 rows=200067 width=0) (actual time=35.927..35.927 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared hit=548 -> BitmapAnd (cost=8685.32..8685.32 rows=1614 width=0) (actual time=92.539..92.539 rows=0 loops=1) Buffers: shared hit=1100 read=56 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.43 rows=8071 width=0) (actual time=3.541..3.541 rows=8186 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#35'::bpchar)) Buffers: shared hit=6 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8392.23 rows=399980 width=0) (actual time=85.749..85.749 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=1094 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.83 rows=8013 width=0) (actual time=3.229..3.229 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=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.058..0.064 rows=0 loops=4867) 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 >= 16::double precision) AND (l_quantity <= 26::double precision)) OR ((l_quantity >= 21::double precision) AND (l_quantity <= 31::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 >= 6::double precision) AND (l_quantity <= 16::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#35'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 16::double precision) AND (l_quantity <= 26::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 >= 21::double precision) AND (l_quantity <= 31::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=50138 read=11060 dirtied=145 Planning time: 3.732 ms Execution time: 585.007 ms (38 rows) COMMIT; COMMIT