当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

2019年01月25日  | 移动技术网IT编程  | 我要评论
背景描述 问题分析 Q1:为什么会产生临时表? 这个不多说,SQL写的惹不起,反正就是半个小时看不懂的那种,就是一眼就知道一定会产生临时表的😂~~~ Q2:登录到机器上去查看内存使用偏小? 因为这个物理机的内存是125G,但是mysql的总数据量不超过1G,所有实际并不需要多少内存就可以将所有数据 ...

背景描述

# time: 2019-01-24t00:08:14.705724+08:00
# user@host: **[**] @  [**]  id: **
# schema: sentrymeta  last_errno: 0  killed: 0
# query_time: 0.315758  lock_time: 0.001693  rows_sent: 9664  rows_examined: 36413  rows_affected: 0
# bytes_sent: 1616970  tmp_tables: 1  tmp_disk_tables: 1  tmp_table_sizes: 16384
# qc_hit: no  full_scan: no  full_join: no  tmp_table: yes  tmp_table_on_disk: yes
# filesort: no  filesort_on_disk: no  merge_passes: 0
#   innodb_io_r_ops: 0  innodb_io_r_bytes: 0  innodb_io_r_wait: 0.000000
#   innodb_rec_lock_wait: 0.000000  innodb_queue_wait: 0.000000
#   innodb_pages_distinct: 1085
             total       used       free     shared    buffers     cached
mem:           125         38         87          0          0         19
-/+ buffers/cache:         18        107
swap:           31          0         31
root@(none)04:33:02>select version();
+---------------+
| version()     |
+---------------+
| 5.7.19-17-log |
+---------------+
1 row in set (0.00 sec)

root@(none)04:33:07>show variables like '%table_size%';
+---------------------+-----------+
| variable_name       | value     |
+---------------------+-----------+
| max_heap_table_size | 134217728 |
| tmp_table_size      | 16777216  |
+---------------------+-----------+
2 rows in set (0.00 sec)

问题分析

q1:为什么会产生临时表?

这个不多说,sql写的惹不起,反正就是半个小时看不懂的那种,就是一眼就知道一定会产生临时表的

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网