小编Igo*_*dov的帖子

Mysql 5.7 与 5.5:简单查询的运行时间要长 50 倍

我有一个数据库“代数”,其中包含一个包含 1,033,990 行的“问题”表。记录有一个属性“已解决”,即 INT。我有一个简单的查询

select count(*) from questions where solved = 0
Run Code Online (Sandbox Code Playgroud)

我有两台 CPU 相似的服务器。在两台服务器上,表是相同的。(数据库是生产的副本)。它们在 SSD 上。一台服务器有 Ubuntu 14.04 和 MySQL 5.5.49,另一台服务器有 Ubuntu 16.04 和 MySQL 5.7.12。

问题是这个查询在 MySQL 5.5 上只需要 0.009s,但在 MySQL 5.7 上需要 0.304s。慢了 34 倍!!!

查询计划大致相似:

服务器慢:

id      select_type     table   partitions      type    possible_keys   key     key_len ref     rows    filtered        Extra
1       SIMPLE  questions       NULL    index   NULL    by_topic_solved 97      NULL    1033990 10.00   Using where; Using index
Run Code Online (Sandbox Code Playgroud)

快速服务器:

id  select_type table   type    possible_keys   key key_len ref rows    Extra
1   SIMPLE …
Run Code Online (Sandbox Code Playgroud)

performance mysql ubuntu

7
推荐指数
1
解决办法
9735
查看次数

标签 统计

mysql ×1

performance ×1

ubuntu ×1