gpt4 book ai didi

mysql - 检查读/写比率的命令?

转载 作者:可可西里 更新时间:2023-11-01 06:28:01 25 4
gpt4 key购买 nike

MySQL 中是否有一个命令返回查询的读写比,以便我能够知道 MySQL 花费了什么时间,以及通过将数据拆分到两个服务器是否会显着降低负载?

最佳答案

此 SQL 命令将为您提供有关读/写比率的指示:

SHOW GLOBAL STATUS WHERE Variable_name = 'Com_insert'
OR Variable_name = 'Com_update'
OR Variable_name = 'Com_select'
OR Variable_name = 'Com_delete';

第三方编辑

在我们的一台服务器上给出了这个结果

  Variable_name    |   Value
Com_delete | 6878
Com_insert | 5975
Com_select | 101061
Com_update | 9026
Bytes_received | 136301641 <-- added by 3rd party
Bytes_sent | 645476511 <-- added by 3rd party

我假设更新和插入具有不同的 IO 含义,但我像这样将它们组合 Com_insert + Com_update/Com_select 以获得“写入/读取”的想法。我还使用 Bytes_received 和 Bytes_sent - 但这可能会导致错误的结论,因为接收到的字节不一定会导致写入磁盘(例如长 where 子句)。

SELECT (136263935/1000000) AS GB_received
, (644471797/1000000) AS GB_sent
, (136263935/644471797) AS Ratio_Received_Sent
, (6199+9108)/106789 AS Ins_Upd_Select_ratio;

这给出了这个结果

GB_received |  GB_sent | Ratio_Received_Sent | Ins_Upd_Select_ratio 
136 | 644 | 0,2114 | 0,1433

关于mysql - 检查读/写比率的命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2214039/

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