call 存储过程,用processlist发现一进程ID一直处于QUERY状态
State:Copying to tmp table on disk,
Info:CREATE TEMPORARY TABLE tmp_transact
- Copying to tmp table on disk The temporary result set was larger than tmp_table_size and the thread is now changing the in memory-based temporary table to a disk based one to save memory.
- 经过查资料发现mysql可以通过变量tmp__table__size和max__heap__table__size来控制内存表大小上限,如果超过上限会将数据写到磁盘tmp__table上,然后返回给客户端,从而多了一次IO)
因为存储过程里面包含大量的临时表,以及左连接,且临时表没有建立索引(SQL太渣,略去);
查看设置:
1 | mysql> show variables like '%tmp%'; |
解决方案:
- 命令行改变配置的命令:
- set global tmp_table_size=1073741824;
- set max_heap_table_size=1073741824;