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#34' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 10 and l_quantity <= 10+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#12' 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=163903.82..163903.83 rows=1 width=8) (actual time=952.654..952.654 rows=1 loops=1) Buffers: shared hit=52201 read=16557 dirtied=27 written=836 -> Nested Loop (cost=25941.84..163895.27 rows=1141 width=8) (actual time=211.203..951.395 rows=1141 loops=1) Buffers: shared hit=52201 read=16557 dirtied=27 written=836 -> Bitmap Heap Scan on part (cost=25941.28..39764.56 rows=4813 width=30) (actual time=211.002..324.063 rows=4816 loops=1) Recheck Cond: (((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#34'::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#12'::bpchar) AND (p_size <= 15) AND (p_size >= 1))) Heap Blocks: exact=4544 Buffers: shared hit=2253 read=5751 written=303 -> BitmapOr (cost=25941.28..25941.28 rows=4817 width=0) (actual time=210.176..210.176 rows=0 loops=1) Buffers: shared hit=1653 read=1807 written=78 -> BitmapAnd (cost=4465.11..4465.11 rows=794 width=0) (actual time=47.105..47.105 rows=0 loops=1) Buffers: shared hit=3 read=606 written=32 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.55 rows=7983 width=0) (actual time=4.189..4.189 rows=8037 loops=1) Index Cond: ((p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (p_brand = 'Brand#34'::bpchar)) Buffers: shared hit=3 read=58 written=8 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..4172.90 rows=198847 width=0) (actual time=41.163..41.163 rows=199678 loops=1) Index Cond: ((p_size <= 5) AND (p_size >= 1)) Buffers: shared read=548 written=24 -> BitmapAnd (cost=8637.53..8637.53 rows=1587 width=0) (actual time=69.719..69.719 rows=0 loops=1) Buffers: shared hit=552 read=602 written=32 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..289.51 rows=7982 width=0) (actual time=3.469..3.469 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 written=2 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..8345.36 rows=397693 width=0) (actual time=64.462..64.462 rows=399409 loops=1) Index Cond: ((p_size <= 10) AND (p_size >= 1)) Buffers: shared hit=548 read=546 written=30 -> BitmapAnd (cost=12838.15..12838.15 rows=2436 width=0) (actual time=92.669..92.669 rows=0 loops=1) Buffers: shared hit=1098 read=599 written=14 -> Bitmap Index Scan on part_p_container_p_brand_p_partkey_idx (cost=0.00..291.19 rows=8147 width=0) (actual time=3.327..3.327 rows=8175 loops=1) Index Cond: ((p_container = ANY ('{"LG CASE","LG BOX","LG PACK","LG PKG"}'::bpchar[])) AND (p_brand = 'Brand#12'::bpchar)) Buffers: shared hit=4 read=55 written=4 -> Bitmap Index Scan on part_p_size_idx (cost=0.00..12544.30 rows=597987 width=0) (actual time=87.622..87.622 rows=598661 loops=1) Index Cond: ((p_size <= 15) AND (p_size >= 1)) Buffers: shared hit=1094 read=544 written=10 -> 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.116..0.125 rows=0 loops=4816) 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 >= 10::double precision) AND (l_quantity <= 20::double precision)) OR ((l_quantity >= 18::double precision) AND (l_quantity <= 28::double precision)) OR ((l_quantity >= 25::double precision) AND (l_quantity <= 35::double precision))) AND (((part.p_brand = 'Brand#34'::bpchar) AND (part.p_container = ANY ('{"SM CASE","SM BOX","SM PACK","SM PKG"}'::bpchar[])) AND (l_quantity >= 10::double precision) AND (l_quantity <= 20::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#12'::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=49948 read=10806 dirtied=27 written=533 Planning time: 4.246 ms Execution time: 953.116 ms (41 rows) COMMIT; COMMIT