【问题标题】:Command to check read/write ratio?检查读/写比率的命令?
【发布时间】:2010-02-06 17:53:31
【问题描述】:

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

【问题讨论】:

    标签: mysql monitoring


    【解决方案1】:

    此 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 - 但这可能会导致错误的结论,因为接收到的字节不一定会导致写入磁盘(例如 long 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 
    

    【讨论】:

    • @Pyhxx 我希望我添加这个例子没问题。您如何认为 Com_update + Com_insert / Com_select 比 bytes_received / bytes_sent 更合适。由于 bytes_received 可能是 SELECT 以及 Insert 和 Update 的信息,我假设这是苹果和橙子。你会将 Com_delete 添加到“读/写”比率吗?
    【解决方案2】:

    您可以使用“显示状态”并检查“Com_%”变量的读/写比率。

    至于拆分数据,您必须检查慢查询日志(Google mysqlsla)并确定这些查询是否适合拆分。

    【讨论】:

      【解决方案3】:

      http://forums.mysql.com/read.php?10,328920,337142#msg-337142

      "SHOW GLOBAL STATUS LIKE 'Com%'。这将给出每种语句类型的总计数(自上次重新启动以来)。这不一定会告诉您主要是 SELECT 绑定还是写入绑定。您可能有一个Com_select 中的数字很小,但选择非常慢。"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-06-10
        • 1970-01-01
        • 2011-02-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多