mariadb 5.5上的异常“扁平,BNL加入”

时间:2019-06-10 10:02:42

标签: mariadb

我有两个mariadb 5.5实例,每个实例具有完全相同的数据和my.cnf参数。 (实际上,我已将所有文件从旧服务器复制到新服务器。)

运行查询时,查询速度很快(<1秒),并向我显示查询的解释如下...(主机#1)

+------+-------------+-----------------+-------+---------------+---------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------+--------+----------------------------------------------+
| id   | select_type | table           | type  | possible_keys | key     | key_len | ref                                                                                                                                                  | rows   | Extra                                        |
+------+-------------+-----------------+-------+---------------+---------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------+--------+----------------------------------------------+
|    1 | PRIMARY     | TABLE1          | index | NULL          | PRIMARY | 130     | NULL                                                                                                                                                 |   9792 | Using where; Using index                     |
|    1 | PRIMARY     | <derived2>      | ref   | key0          | key0    | 135     | testdb.TABLE1.COL1,testdb.TABLE1.COL2,testdb.TABLE1.COL3,testdb.TABLE1.COL4,testdb.TABLE1.COL5                                                       |     30 |                                              |
|    2 | DERIVED     | TABLE2          | range | PRIMARY       | PRIMARY | 8       | NULL                                                                                                                                                 | 299012 | Using where; Using temporary; Using filesort |
+------+-------------+-----------------+-------+---------------+---------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------+--------+----------------------------------------------+

另一个人运行了很长时间(超过15秒),并向我显示了以下不同的解释...(主机#2)

+------+-------------+-----------------+-------+---------------+-------------------+---------+------+--------+-------------------------------------------------+
| id   | select_type | table           | type  | possible_keys | key               | key_len | ref  | rows   | Extra                                           |
+------+-------------+-----------------+-------+---------------+-------------------+---------+------+--------+-------------------------------------------------+
|    1 | PRIMARY     | TABLE1          | index | NULL          | PRIMARY           | 130     | NULL |   8123 | Using index                                     |
|    1 | PRIMARY     | <derived2>      | ALL   | NULL          | NULL              | NULL    | NULL | 294954 | Using where; Using join buffer (flat, BNL join) |
|    2 | DERIVED     | TABLE2          | range | PRIMARY       | PRIMARY           | 8       | NULL | 294954 | Using where; Using temporary; Using filesort    |
+------+-------------+-----------------+-------+---------------+-------------------+---------+------+--------+-------------------------------------------------+

当我在主机#1上意外将derived_with_keys设置为off时,结果与主机#2相同,并且我认为主机#1选择了{#1}}操作,而主机#2却没有。

如何强制我的新服务器使用derived_with_keys

任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

问题解决了。

有两个不同的字符集(UTF8和LATIN1)

ALTER TABLE TABLE2 CONVERT TO CHARACTER SET UTF8之后,它可以正常工作。

感谢里克·詹姆斯。