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#15' 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#11' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 18 and l_quantity <= 18+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#35' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 30 and l_quantity <= 30+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=164105.64..164105.65 rows=1 width=8) (actual time=786.214..786.214 rows=1 loops=1) Buffers: shared hit=47438 read=20710 dirtied=62 written=11 -> Nested Loop (cost=25941.93..164096.98 rows=1154 width=8) (actual time=292.700..785.462 rows=1110 loops=1) Buffers: shared hit=47438 read=20710 dirtied=62 written=11 -> Bitmap Heap Scan on part (cost=25941.37..39779.86 rows=4820 width=30) (actual time=292.585..370.282 rows=4766 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#15'::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#11'::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#35'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4464 Buffers: shared hit=1954 read=5970 written=5 -> BitmapOr (cost=25941.37..25941.37 rows=4823 width=0) (actual time=291.664..291.664 rows=0 loops=1) Buffers: shared hit=1653 read=1807 written=1 -> BitmapAnd (cost=4464.91..4464.91 rows=792 width=0) (actual time=60.002..60.002 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.35 rows=7963 width=0) (actual time=4.193..4.193 rows=8004 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#15'::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=53.370..53.370 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 -> BitmapAnd (cost=8637.53..8637.53 rows=1587 width=0) (actual time=94.434..94.434 rows=0 loops=1) Buffers: shared hit=552 read=602 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.51 rows=7982 width=0) (actual time=3.719..3.719 rows=7852 loops=1) Index Cond: ((p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (p_brand = 'Brand#11'::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=88.099..88.099 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 -> BitmapAnd (cost=12838.43..12838.43 rows=2445 width=0) (actual time=136.462..136.462 rows=0 loops=1) Buffers: shared hit=1098 read=600 written=1 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..291.47 rows=8176 width=0) (actual time=3.721..3.721 rows=8038 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#35'::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=130.106..130.106 rows=598661 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=1094 read=544 written=1 -> 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.078..0.084 rows=0 loops=4766) 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 >= 18::double precision) AND (l_quantity <= 28::double precision)) OR ((l_quantity >= 30::double precision) AND (l_quantity <= 40::double precision))) AND (((part.p_brand = 'Brand#15'::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#11'::bpchar) AND (part.p_container = ANY ('{"MED BAG","MED BOX","MED PKG","MED PACK"}'::bpchar[])) AND (l_quantity >= 18::double precision) AND (l_quantity <= 28::double precision) AND (part.p_size <= 10)) OR ((part.p_brand = 'Brand#35'::bpchar) AND (part.p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (l_quantity >= 30::double precision) AND (l_quantity <= 40::double precision) AND (part.p_size <= 15)))) Rows Removed by Filter: 4 Buffers: shared hit=45484 read=14740 dirtied=62 written=6 Planning time: 4.629 ms Execution time: 786.678 ms (41 rows) COMMIT; COMMIT