joshuapl

MySQL 5.1.52 bug?

Mar 8th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 3.67 KB | None | 0 0
  1. This seems to be a bug in MySQL 5.1.52. The same query is processed differently before MySQL daemon restart and after restart. Before restart MySQL is performing a week or so, and starts working really slowly. Seems, that optimization is not performed. After restart, everything is OK again.
  2.  
  3. BEFORE MySQL restart (przed restartem):
  4.  
  5. mysql> explain SELECT BS.ID,ROOT_ID,CMT.COMP_TYPE FROM TAB_3M AS BS JOIN TAB_60 AS CMT ON BS.COMP_TYPE_ID=CMT.ID JOIN TAB_9K AS TR ON BS.ROOT_ID=TR.ATTR_ID WHERE (IFNULL(TR.LATEST_TERM,(NOW() + INTERVAL 1 DAY))>NOW()) AND TR.STATUS & 13=13 AND ( (CMT.COMP_TYPE IN ("string0") AND (IFNULL(COMP_KEYWORD,'')='')) OR  PROTOTYPE_ID IN ("string1","string2"))  ORDER BY COMP_NAME, ROOT_ID, LFT;
  6. +----+-------------+-------+--------+-----------------------------------+---------+---------+--------------------+---------+-----------------------------+
  7. | id | select_type | table | type   | possible_keys                     | key     | key_len | ref                | rows    | Extra                       |
  8. +----+-------------+-------+--------+-----------------------------------+---------+---------+--------------------+---------+-----------------------------+
  9. |  1 | SIMPLE      | BS    | ALL    | PROTOTYPE_ID,ROOT_ID,COMP_TYPE_ID | NULL    | NULL    | NULL               | 3121118 | Using where; Using filesort |
  10. |  1 | SIMPLE      | TR    | eq_ref | PRIMARY                           | PRIMARY | 8       | db.BS.ROOT_ID      |       1 | Using where                 |  
  11. |  1 | SIMPLE      | CMT   | eq_ref | PRIMARY,COMP_TYPE                 | PRIMARY | 8       | db.BS.COMP_TYPE_ID |       1 | Using where                 |  
  12. +----+-------------+-------+--------+-----------------------------------+---------+---------+--------------------+---------+-----------------------------+
  13. 3 rows in set (0.00 sec)
  14.  
  15. AFTER MySQL restart (po restarcie):
  16.  
  17. mysql> explain SELECT BS.ID,ROOT_ID,CMT.COMP_TYPE FROM TAB_3M AS BS JOIN TAB_60 AS CMT ON BS.COMP_TYPE_ID=CMT.ID JOIN TAB_9K AS TR ON BS.ROOT_ID=TR.ATTR_ID WHERE (IFNULL(TR.LATEST_TERM,(NOW() + INTERVAL 1 DAY))>NOW()) AND TR.STATUS & 13=13 AND ( (CMT.COMP_TYPE IN ("string0") AND (IFNULL(COMP_KEYWORD,'')='')) OR  PROTOTYPE_ID IN ("string1","string2"))  ORDER BY COMP_NAME, ROOT_ID, LFT;
  18. +----+-------------+-------+--------+-----------------------------------+-------------+---------+--------------------+------+-----------------------------------------------------------+
  19. | id | select_type | table | type   | possible_keys                     | key         | key_len | ref                | rows | Extra                                                     |
  20. +----+-------------+-------+--------+-----------------------------------+-------------+---------+--------------------+------+-----------------------------------------------------------+
  21. |  1 | SIMPLE      | TR    | index  | PRIMARY                           | TR_STATUS_2 | 6       | NULL               | 7622 | Using where; Using index; Using temporary; Using filesort |
  22. |  1 | SIMPLE      | BS    | ref    | PROTOTYPE_ID,ROOT_ID,COMP_TYPE_ID | ROOT_ID     | 9       | db.TR.ATTR_ID      |  146 | Using where                                               |  
  23. |  1 | SIMPLE      | CMT   | eq_ref | PRIMARY,COMP_TYPE                 | PRIMARY     | 8       | db.BS.COMP_TYPE_ID |    1 | Using where                                               |  
  24. +----+-------------+-------+--------+-----------------------------------+---------------+---------+------------------+------+-----------------------------------------------------------+
  25. 3 rows in set (0.00 sec)
  26.  
  27. Explanation:
  28. TAB_3M - table with about 3 million rows
  29. TAB_9K - table with about 9 thousand rows
  30. TAB_60 - table with about 60 rows
Advertisement
Add Comment
Please, Sign In to add comment