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 >= 2 and l_quantity <= 2+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#14' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 13 and l_quantity <= 13+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 >= 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=164160.76..164160.77 rows=1 width=8) (actual time=803.330..803.331 rows=1 loops=1) Buffers: shared hit=48612 read=18848 dirtied=79 written=13 -> Nested Loop (cost=25942.34..164152.08 rows=1157 width=8) (actual time=271.503..802.601 rows=1137 loops=1) Buffers: shared hit=48612 read=18848 dirtied=79 written=13 -> Bitmap Heap Scan on part (cost=25941.77..39782.84 rows=4822 width=30) (actual time=270.020..351.634 rows=4716 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#14'::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) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4447 Buffers: shared hit=2875 read=5032 written=4 -> BitmapOr (cost=25941.77..25941.77 rows=4825 width=0) (actual time=269.155..269.155 rows=0 loops=1) Buffers: shared hit=2211 read=1249 -> BitmapAnd (cost=4465.03..4465.03 rows=793 width=0) (actual time=51.052..51.052 rows=0 loops=1) Buffers: shared hit=552 read=56 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.47 rows=7974 width=0) (actual time=4.196..4.196 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=4 read=56 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4172.90 rows=198847 width=0) (actual time=44.527..44.527 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared hit=548 -> BitmapAnd (cost=8638.29..8638.29 rows=1602 width=0) (actual time=91.925..91.925 rows=0 loops=1) Buffers: shared hit=561 read=593 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.27 rows=8055 width=0) (actual time=3.837..3.837 rows=7877 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#14'::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=85.824..85.824 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=557 read=537 -> BitmapAnd (cost=12837.95..12837.95 rows=2431 width=0) (actual time=125.455..125.455 rows=0 loops=1) Buffers: shared hit=1098 read=600 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..290.99 rows=8130 width=0) (actual time=3.614..3.614 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 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12544.30 rows=597987 width=0) (actual time=119.540..119.540 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.084..0.093 rows=0 loops=4716) 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 >= 2::double precision) AND (l_quantity <= 12::double precision)) OR ((l_quantity >= 13::double precision) AND (l_quantity <= 23::double precision)) OR ((l_quantity >= 25::double precision) AND (l_quantity <= 35::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 >= 2::double precision) AND (l_quantity <= 12::double precision) AND (part.p_size <= 5)) OR ((part.p_brand = 'Brand#14'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 13::double precision) AND (l_quantity <= 23::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 >= 25::double precision) AND (l_quantity <= 35::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=45737 read=13816 dirtied=79 written=9 Planning time: 4.283 ms Execution time: 803.722 ms (41 rows) COMMIT; COMMIT