Bug #12144 | 4.1 has wrong estimate of number of rows; explain & max_join_size wrong | ||
---|---|---|---|
Submitted: | 25 Jul 2005 0:37 | Modified: | 6 Aug 2005 23:40 |
Reporter: | Timothy Smith | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 4.1 | OS: | Any (all) |
Assigned to: | Igor Babaev | CPU Architecture: | Any |
[25 Jul 2005 0:37]
Timothy Smith
[25 Jul 2005 1:38]
Timothy Smith
Hmmm, trouble uploading the file to the bug report. Please see the file as uploaded to the FTP site: ftp://ftp.mysql.com/pub/mysql/upload/bug12144.sql.gz Thanks! Timothy
[28 Jul 2005 20:31]
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/27687
[28 Jul 2005 23:05]
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/27697
[29 Jul 2005 0:54]
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/27702
[31 Jul 2005 11:21]
Igor Babaev
The SELECT query SELECT SQL_CALC_FOUND_ROWS orgs.org_id FROM orgs orgs LEFT JOIN contacts contacts ON orgs.org_id=contacts.org_id LEFT JOIN sa_opportunities sa_opportunities ON contacts.c_id=sa_opportunities.c_id GROUP BY orgs.org_id ORDER BY NULL LIMIT 0,1000; was slow by the following reasons. The first left join yielded 5127 rows: mysql> SELECT count(*) FROM orgs LEFT JOIN contacts ON orgs.org_id=contacts.org_id -> WHERE contacts.c_id IS NULL; +----------+ | count(*) | +----------+ | 5127 | +----------+ Thus the table sa_opportunities was accessed 5127 times with key=NULL. The table sa_opportunities had 21296 rows with c_id=NULL mysql> SELECT count(*) FROM sa_opportunities WHERE c_id IS NULL; +----------+ | count(*) | +----------+ | 21296 | +----------+ So there were 5127*21296 calls of handler read_next.
[31 Jul 2005 11:28]
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/27752
[1 Aug 2005 5:19]
Igor Babaev
This patch is in 3 changesets. ChangeSet 1.2347 05/07/28 13:31:15 igor@rurik.mysql.com +3 -0 sql_select.cc: Fixed bug #12144. Added an optimization that avoids key access with null keys for the 'ref' method when used in outer joins. The regilar optimization with adding IS NOT NULL expressions is not applied for outer join on expressions as the predicates of these expressions are not pushed down in 4.1. null_key.result, null_key.test: Added a test case for bug #12144. ChangeSet 1.2357 05/07/28 16:04:47 igor@rurik.mysql.com +2 -0 null_key.test, null_key.result: Modified the test case for patch of the bug #12144 to display status of Handler_read_next before and after the tested query. ChangeSet 1.2358 05/07/28 17:53:51 igor@rurik.mysql.com +2 -0 null_key.test, null_key.result: Made the test case for bug #12144 independent on other tests. The fix will appear in 4.1.14 and 5.0.11
[6 Aug 2005 23:40]
Mike Hillyer
Documented in 4.1.14 and 5.0.11 changelogs: <listitem><para> Added an optimization that avoids key access with <literal>NULL</literal> keys for the <literal>ref</literal> method when used in outer joins. (Bug #12144) </para></listitem>