Bug #11608 Explain select gives two different output, which makes optimisation difficult
Submitted: 28 Jun 2005 10:58 Modified: 1 Aug 2005 15:44
Reporter: Sumit Kumar Roy Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:4.0.17 OS:Linux (Linux Kernal 2.24)
Assigned to: CPU Architecture:Any

[28 Jun 2005 10:58] Sumit Kumar Roy
Description:
While optimising a query using "explain select " we found the following misleading outputs:
mysql> explain select f.idFile,f.idClass,f.idStorageContainer,f.SharingContainer,n.RelativeName,d.AbsolutePath,n.mtime from NameSpaceEntry n use index (index2),DirEntry d use index (PRIMARY), FileEntry f use index (index1) where (n.idNameSpaceEntry = f.idFile) AND (n.ParentEntry=d.idDirEntry) AND f.idFile is not NULL AND f.Hash is NULL AND f.WriteLock = 0 AND n.mtime > '-1' AND f.idStorageContainer <> 0 AND f.idFile > 0 AND f.ReferenceCount = 0 AND n.WORMActive = 1 AND f.Valid = 'V
ALID' ORDER BY n.mtime;

+-------+--------+---------------+---------+---------+---------------+----------+----------------------------------------------+

| table | type   | possible_keys | key     | key_len | ref           | rows     | Extra                                        |

+-------+--------+---------------+---------+---------+---------------+----------+----------------------------------------------+

| f     | range  | index1        | index1  |       8 | NULL          |  3537335 | Using where; Using temporary; Using filesort |

| n     | ALL    | index2        | NULL    |    NULL | NULL          | 30014912 | Using where                                  |

| d     | eq_ref | PRIMARY       | PRIMARY |       8 | n.ParentEntry |        1 |                                              |

+-------+--------+---------------+---------+---------+---------------+----------+----------------------------------------------+

3 rows in set (0.00 sec)

 

mysql> explain select f.idFile,f.idClass,f.idStorageContainer,f.SharingContainer,n.RelativeName,d.AbsolutePath,n.mtime from NameSpaceEntry n use index (index2),DirEntry d use index (PRIMARY), FileEntry f use index (index1) where (n.idNameSpaceEntry = f.idFile) AND (n.ParentEntry=d.idDirEntry) AND f.idFile is not NULL AND f.Hash is NULL AND f.WriteLock = 0 AND n.mtime > '-1' AND f.idStorageContainer <> 0 AND f.idFile > 0 AND f.ReferenceCount = 0 AND n.WORMActive = 1 AND f.Valid = 'V
ALID' ORDER BY n.mtime;

+-------+--------+---------------+---------+---------+--------------------------------------+----------+-------------+

| table | type   | possible_keys | key     | key_len | ref                                  | rows     | Extra       |

+-------+--------+---------------+---------+---------+--------------------------------------+----------+-------------+

| n     | index  | index2        | index2  |      43 | NULL                                 | 30014937 | Using where |

| d     | eq_ref | PRIMARY       | PRIMARY |       8 | n.ParentEntry                        |        1 |             |

| f     | ref    | index1        | index1  |      82 | n.idNameSpaceEntry,const,const,const |  5081496 | Using where |

+-------+--------+---------------+---------+---------+--------------------------------------+----------+-------------+
3 rows in set (0.00 sec)

Also in the API the select statement executes creating temporary files, which increases the response time.

How to repeat:
Run the "explain " on any sql syntax consequtively.
[1 Jul 2005 15:44] MySQL Verification Team
Do you get different EXPLAIN outputs for the _same_ data on the _same_ box randomly?

Please, be more detailed.
[1 Aug 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".