Bug #10561 | "NOT field IN(valuelist)" doesn't use indexes when it could | ||
---|---|---|---|
Submitted: | 11 May 2005 16:21 | Modified: | 23 May 2005 1:51 |
Reporter: | Dan Nelson | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 4.1.11 | OS: | FreeBSD (FreeBSD) |
Assigned to: | Igor Babaev | CPU Architecture: | Any |
[11 May 2005 16:21]
Dan Nelson
[11 May 2005 18:20]
Hartmut Holzgraefe
At first i thought that this was because first the rather big result of IN() would be processed and only after that it would be negated, leading to a full table scan as most rows match the IN() part. But then i tried the following: EXPLAIN SELECT * FROM test WHERE NOT ( status ='A' OR status='B'); +----+-------------+-------+-------+---------------+--------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+--------+---------+------+------+-------------+ | 1 | SIMPLE | test | range | status | status | 23 | NULL | 11 | Using where | +----+-------------+-------+-------+---------------+--------+---------+------+------+-------------+ so this might not necessarily be a bug but at least someone with more detail knowledge than me should look over ...
[21 May 2005 8:39]
Igor Babaev
This is actually an optimization request.
[21 May 2005 13:12]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/25156
[21 May 2005 14:09]
Igor Babaev
The optimization feature will appear in release 5.0.7. It could be applied to 4.1 as well, but our policy prohibits us to add new features in production releases. ChangeSet 1.1894 05/05/21 06:11:44 igor@rurik.mysql.com +4 -0 range.result, range.test: Added test cases for optimization request #10561. opt_range.cc, sql_select.cc: Fixed bug #10561: an optimization request to allow range analysis for NOT IN and NOT BETWEEN.
[23 May 2005 1:51]
Paul DuBois
Noted in 5.0.7 changelog.