简体   繁体   English

mysql创建临时表很慢

[英]mysql creation of temp table very slow

I am using mysql in 2 different systems. 我在2个不同的系统中使用mysql。 I have 1 system with ubuntu and another one with debian. 我有一个使用ubuntu的系统,另一个使用了debian。

I have to create a temp table at some point in order to present the data and what is really strange is that on the ubuntu system, it takes 400 ms (response from browser) and on the debian it takes more than 10 seconds !!! 为了显示数据,我必须在某个时候创建​​一个临时表,真正奇怪的是,在ubuntu系统上,它需要400毫秒(来自浏览器的响应),而在debian上则需要10秒钟以上!

I have checked 2 values in the mysql config and I have: show global variables like 'tmp_table_size'; 我已经检查了mysql配置中的2个值,并且有:显示全局变量,如“ tmp_table_size”; which is the same on both servers: 16777216 两台服务器上的相同:16777216

But the difference is: show global status like 'created_tmp_disk_tables'; 但是区别是:显示全局状态,例如“ created_tmp_disk_tables”; which gives 11 on the fast server and 102 on the slow server. 在快速服务器上为11,在慢速服务器上为102。

I don't really know where else to look and how to optimise it so that I have the same on both servers. 我真的不知道该在哪里寻找其他内容以及如何对其进行优化,以便两台服务器上都具有相同的外观。

Of course my production server is on the debian. 当然,我的生产服务器在debian上。

The fast server is running: mysql version 5.7.18-0ubuntu0.16.04.1 The slow server is running: mysql version 5.5.55-0+deb8u1 快速服务器正在运行:mysql版本5.7.18-0ubuntu0.16.04.1慢速服务器正在运行:mysql版本5.5.55-0 + deb8u1

On the fast server, I have: 在快速服务器上,我有:

show global variables like 'default_tmp_storage_engine';
+----------------------------+--------+
| Variable_name              | Value  |
+----------------------------+--------+
| default_tmp_storage_engine | InnoDB |
+----------------------------+--------+
1 row in set (0.00 sec)

On the slow server, I have: 在速度较慢的服务器上,我有:

show global variables like 'default_tmp_storage_engine';
Empty set (0.00 sec)

Suggestion to consider for your my.cnf-ini 建议为您的my.cnf-ini考虑

max_heap_table_size=16M  # and should always be same as tmp_table_size

SHOW GLOBAL VARIABLES LIKE '%tmp_table_size' may be used on each version to see what you have at this time. 显示全局变量,例如'%tmp_table_size'可以在每个版本上使用,以查看此时的内容。

Global variable default_tmp_storage_engine was added between 5.5 and 5.7. 在5.5和5.7之间添加了全局变量default_tmp_storage_engine。

For additional assistance please find contact information in my profile. 如需其他帮助,请在我的个人资料中找到联系信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM