gpt4 book ai didi

MySQL 5.5 性能

转载 作者:行者123 更新时间:2023-11-29 01:45:04 25 4
gpt4 key购买 nike

我们最近将 mysql 从 5.1 升级到 5.5.17 版本。因此,许多在 5.1 中运行良好的查询的性能已经严重下降。我开始更新查询,但要更新的查询太多了。我想知道这里是否有人已经经历过这个并且有更好的主意。

编辑1:例如,我意识到与 5.1 相比,在 5.5 中连接两个表并具有使用 contant 的 where 条件的查询确实很慢。在其中一个表中添加常量值并在连接中使用它有帮助。所以在下面的查询中,第二个比第一个快得多。

select t1.* 
from t1, t2
where t1.field1 = t2.field1
and t1.field2 = 100;

"id" "select_type" "table" "type" "possible_keys" "key" "key_len" "ref" "rows" "Extra"
"1" "SIMPLE" "t1" "ALL" "PRIMARY" \N \N \N "1" "Using where"
"1" "SIMPLE" "t2" "eq_ref" "PRIMARY" "PRIMARY" "152" "t1.field1" "1" "Using index"

select t1.*
from t1, t2
where t1.field1 = t2.field1
and t1.field2 = t2.field2; -- i added a col field2 in t2 with value = 100

"id" "select_type" "table" "type" "possible_keys" "key" "key_len" "ref" "rows" "Extra"
"1" "SIMPLE" "t1" "ALL" "PRIMARY" \N \N \N "1" ""
"1" "SIMPLE" "t2" "eq_ref" "PRIMARY" "PRIMARY" "152" "t1.field1" "1" "Using where"

最佳答案

在某些情况下,MySQL 5.1 有时可能优于 MySQL 5.5。

Percona performed a bake-off among multiple releases of MySQL

  • MySQL 4.1
  • MySQL 5.0
  • MySQL 5.1(内置 InnoDB)
  • 带有 InnoDB 插件的 MySQL 5.1
  • MySQL 5.5
  • MySQL 5.6

所有测试都是在未配置 MySQL 的情况下执行的(换句话说,没有创建 my.cnf)。结果呢?

  • MySQL 4.1 执行最好的单线程
  • 带有 InnoDB 插件的 MySQL 5.1 在多核上的扩展优于 5.1 内置 InnoDB、5.5 和 5.6

如果您希望较新版本的 MySQL 性能更好,则必须对其进行调优。事实上,I described in the DBA StackExchange the idea of performing a MySQL Bakeoff .

为它调音是什么意思?

在 MySQL 5.5 中,there are new InnoDB options for utilizing more dedicated read threads, write threads, and overall I/O capacity .这可以在多核服务器中使用更多的 CPU。 未配置,在大多数情况下,MySQL 5.5 将在与旧版本 MySQL 相同的水平上运行。有时,它的性能可能更差。

关于MySQL 5.5 性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9202825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com