从MySQL5.5升级后Percona5.7缓慢“发送数据”

3j86kqsm  于 2021-06-17  发布在  Mysql
关注(0)|答案(3)|浏览(351)

将MySQL5.5升级到Percona5.7后,应用程序运行非常缓慢。我无法优化查询,因为这些查询是用应用程序编译的。我唯一能做的就是优化mysql服务器(或服务器配置)
我需要提到的是,我看到一些查询返回大量数据(70m的结果)data dir在ssd上。我有32g ram,但我为mysql分配了20个(60%是因为我们还有其他小型服务)
如果我激活缓存,我会注意到一个小的改进(这将被弃用)
下面是我的配置
在此处显示全局状态结果
有人知道如何改进mysql配置或服务器以提高性能吗?我用一个带explain的sql作为例子。它返回672行数据,但需要30秒(29行停留在“发送数据”中)。

explain select l.idCodeLocation as idLocation, l.txLocation as name, l.radius as radius, l.amLat as lat, l.amLong as lng, g.isin as isin, g.isout as isout, g.onval as onval, m.isGeofenceIn as isGeofenceIn, m.geofenceInTime as geofenceInTime, m.isGeofenceOn as isGeofenceOn, v.idVeh as idveh, v.idPlateVeh as plate, v.idClient as client from sat_geofence g left join sat_clientLocation as l on (g.idLocation=l.idCodeLocation) join sat_geofence_vehicle_mtm as m on (g.idLocation=m.idLocation) join sat_vehicle as v on (m.idVeh=v.idVeh);
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+--------+----------+----------------------------------------------------+
| id | select_type | table | partitions | type   | possible_keys | key     | key_len | ref               | rows   | filtered | Extra                                              |
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+--------+----------+----------------------------------------------------+
|  1 | SIMPLE      | g     | NULL       | ALL    | idx           | NULL    | NULL    | NULL              |     38 |   100.00 | NULL                                               |
|  1 | SIMPLE      | m     | NULL       | ref    | idx           | idx     | 768     | Stdb.g.idLocation |      5 |   100.00 | Using index condition                              |
|  1 | SIMPLE      | v     | NULL       | eq_ref | PRIMARY       | PRIMARY | 3       | Stdb.m.idVeh      |      1 |   100.00 | Using where                                        |
|  1 | SIMPLE      | l     | NULL       | ALL    | NULL          | NULL    | NULL    | NULL              | 116952 |   100.00 | Using where; Using join buffer (Block Nested Loop) |
+----+-------------+-------+------------+--------+---------------+---------+---------+-------------------+--------+----------+----------------------------------------------------+

我放在这里的表格结构:https://gist.github.com/costyoancea/deee560f9c94aa2463162d7ce0556392
谢谢,科斯蒂

eimct9ow

eimct9ow1#

您缺少m.idveh的索引。参考卫星\地理围栏\车辆\ mtm。请在第一个位置加上这个简单的索引。要获得优化帮助,请查看我的个人资料、联系信息的网络个人资料。在商店页面上查看我的评论。

8iwquhpp

8iwquhpp2#

group_concat_max_len = 18446744073709565  -- dangerously large.

请提供 SHOW GLOBAL STATUS 以帮助进行调整分析。你有多少公羊?
即使您无法更改查询,也请将其显示给我们。我们也许可以建议一个有帮助的索引。

rdlzhqv9

rdlzhqv93#

linux ulimit-a限制的建议

ulimit -n 65536       to increase Open File limit from 1024

要允许此值在linux关闭/重新启动期间持续存在,请查看此内容,
https://glassonionblog.wordpress.com/2013/01/27/increase-ulimit-and-file-descriptors-limit/
由于操作系统版本的不同,您的详细信息可能略有不同。
rate per second=rps为my.cnf[mysqld]部分考虑的建议

join_buffer_size=128K  # from 128M for a more reasonable RAM request per connection
sort_buffer_size=2M  # from ~256M for a more reasonable RAM request per connection
innodb_lru_scan_depth=100  # from 1024 to reduce CPU cycles used every SECOND
innodb_flushing_avg_loops=5  # from 30 to reduce innodb_buffer_pool_pages_dirty 5,692
table_open_cache=10000  # from 4096 to reduce opened_tables RPHr 40,456 
open_table_definitions=10000  # from 400 to reduce opened_table_definitions RPHr 21,459
thread_cache_size=100  # from 14 to reduce threads_created from 64

期待您的反馈和评论后7天在我的网站上发布,请。

相关问题