AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 3120
Accepted
spoulson
spoulson
Asked: 2009-05-03 07:08:27 +0800 CST2009-05-03 07:08:27 +0800 CST 2009-05-03 07:08:27 +0800 CST

我如何分析 MySQL?

  • 772

有哪些工具可以分析 MySQL,例如 MSSQL 2000+ 如何使用 SQL Profiler?

我想跟踪诸如执行的 SQL 语句、执行时间、执行计划等内容。

performance mysql
  • 9 9 个回答
  • 18190 Views

9 个回答

  • Voted
  1. Best Answer
    David Schmitt
    2009-05-03T07:15:07+08:002009-05-03T07:15:07+08:00

    查看启用Query Log和Slow Query Log。

    • 11
  2. pQd
    2009-05-22T10:00:46+08:002009-05-22T10:00:46+08:00

    如果您在生产/测试环境中打开了查询日志记录[这不是必需的],您可以使用maatkit工具包中的 mk-query-digest。它将帮助您确定哪些查询最频繁/耗时等。

    • 5
  3. talonx
    2009-07-07T20:23:30+08:002009-07-07T20:23:30+08:00

    您还可以查看MySQLTuner

    • 3
  4. Travis Campbell
    2009-07-22T11:46:34+08:002009-07-22T11:46:34+08:00

    另一个商业选项是MySQL 查询分析器,它是 MySQL Enterprise Monitor 的一部分。我发现它在帮助分析奇怪的查询以找出提高其性能的方法方面非常有用。

    • 3
  5. Node
    2009-05-03T07:13:51+08:002009-05-03T07:13:51+08:00

    这是一篇关于 MySQL 分析器的好文章。虽然看一下解释语句。

    • 2
  6. mercutio
    2009-05-03T09:10:21+08:002009-05-03T09:10:21+08:00

    我使用这个小脚本。它一直对我有用,虽然不是官方的。

    http://genomewiki.ucsc.edu/index.php/Tuning-primer.sh

    • 0
  7. Jarod Elliott
    2009-05-22T13:50:13+08:002009-05-22T13:50:13+08:00

    我使用了几个脚本和其他工具,它们都很棒,但我发现Jet Profiler非常擅长实时监控和可视化正在发生的事情以及事情的变化方式。完整版要花钱,但受限制的免费版也很有用,可以让您很好地了解完整版的功能。

    • 0
  8. Paul
    2013-07-17T06:41:00+08:002013-07-17T06:41:00+08:00

    请参阅:https ://sites.google.com/site/basicsqlmanagment/为我工作,不是代理分析器

    • 0
  9. RolandoMySQLDBA
    2013-07-17T09:17:37+08:002013-07-17T09:17:37+08:00

    我强烈推荐以下

    • pt-查询-摘要
    • mk-query-digest(过时但仍然有效)

    来自旧的 MAATKIT 文档

     Column        Meaning
     ============  ==========================================================
     Rank          The query's rank within the entire set of queries analyzed
     Query ID      The query's fingerprint
     Response time The total response time, and percentage of overall total
     Calls         The number of times this query was executed
     R/Call        The mean response time per execution
     Apdx          The Apdex score; see --apdex-threshold for details
     V/M           The Variance-to-mean ratio of response time
     EXPLAIN       If --explain was specified, a sparkline; see --explain
     Item          The distilled query
    

    在 DBA StackExchange 我回答了MySQL 一般查询日志的性能影响。在我的旧帖子中,我建议使用 mk-query-digest 而不是一般日志或慢日志。从那篇文章中,这里是 mk-query-digest 完成的查询分析的示例输出:

    # Rank Query ID           Response time    Calls   R/Call     Item
    # ==== ================== ================ ======= ========== ====
    #    1 0x812D15015AD29D33   336.3867 68.5%     910   0.369656 SELECT mt_entry mt_placement mt_category
    #    2 0x99E13015BFF1E75E    25.3594  5.2%     210   0.120759 SELECT mt_entry mt_objecttag
    #    3 0x5E994008E9543B29    16.1608  3.3%      46   0.351321 SELECT schedule_occurrence schedule_eventschedule schedule_event schedule_eventtype schedule_event schedule_eventtype schedule_occurrence.start
    #    4 0x84DD09F0FC444677    13.3070  2.7%      23   0.578567 SELECT mt_entry
    #    5 0x377E0D0898266FDD    12.0870  2.5%     116   0.104199 SELECT polls_pollquestion mt_category
    #    6 0x440EBDBCEDB88725    11.5159  2.3%      21   0.548376 SELECT mt_entry
    #    7 0x1DC2DFD6B658021F    10.3653  2.1%      54   0.191949 SELECT mt_entry mt_placement mt_category
    #    8 0x6C6318E56E149036     8.8294  1.8%      44   0.200667 SELECT schedule_occurrence schedule_eventschedule schedule_event schedule_eventtype schedule_event schedule_eventtype schedule_occurrence.start
    #    9 0x392F6DA628C7FEBD     8.5243  1.7%       9   0.947143 SELECT mt_entry mt_objecttag
    #   10 0x7DD2B294CFF96961     7.3753  1.5%      70   0.105362 SELECT polls_pollresponse
    #   11 0x9B9092194D3910E6     5.8124  1.2%      57   0.101973 SELECT content_specialitem content_basecontentitem advertising_product organizations_neworg content_basecontentitem_item_attributes
    #   12 0xA909BF76E7051792     5.6005  1.1%      55   0.101828 SELECT mt_entry mt_objecttag mt_tag
    #   13 0xEBE07AC48DB8923E     5.5195  1.1%      54   0.102213 SELECT rssfeeds_contentfeeditem
    #   14 0x3E52CF0261A7C3FF     4.4676  0.9%      44   0.101536 SELECT schedule_occurrence schedule_occurrence.start
    #   15 0x9D0BCD3F6731195B     4.2804  0.9%      41   0.104401 SELECT mt_entry mt_placement mt_category
    #   16 0x7961BD4C76277EB7     4.0143  0.8%      18   0.223014 INSERT UNION UPDATE UNION mt_session
    #   17 0xD2F486BA41E7A623     3.1448  0.6%      21   0.149754 SELECT mt_entry mt_placement mt_category mt_objecttag mt_tag
    #   18 0x3B9686D98BB8E054     2.9577  0.6%      11   0.268885 SELECT mt_entry mt_objecttag mt_tag
    #   19 0xBB2443BF48638319     2.7239  0.6%       9   0.302660 SELECT rssfeeds_contentfeeditem
    #   20 0x3D533D57D8B466CC     2.4209  0.5%      15   0.161391 SELECT mt_entry mt_placement mt_category
    

    此输出上方是这 20 个性能最差的查询的直方图

    第一个条目的直方图示例

    # Query 1: 0.77 QPS, 0.28x concurrency, ID 0x812D15015AD29D33 at byte 0 __
    # This item is included in the report because it matches --limit.
    #              pct   total     min     max     avg     95%  stddev  median
    # Count         36     910
    # Exec time     58    336s   101ms      2s   370ms   992ms   230ms   393ms
    # Lock time      0       0       0       0       0       0       0       0
    # Users                  1      mt
    # Hosts                905 10.64.95.74:54707 (2), 10.64.95.74:56133 (2), 10.64.95.80:33862 (2)... 901 more
    # Databases              1     mt1
    # Time range 1321642802 to 1321643988
    # bytes          1   1.11M   1.22k   1.41k   1.25k   1.26k   25.66   1.20k
    # id            36   9.87G  11.10M  11.11M  11.11M  10.76M    0.12  10.76M
    # Query_time distribution
    #   1us
    #  10us
    # 100us
    #   1ms
    #  10ms
    # 100ms  ################################################################
    #    1s  ###
    #  10s+
    # Tables
    #    SHOW TABLE STATUS FROM `mt1` LIKE 'mt_entry'\G
    #    SHOW CREATE TABLE `mt1`.`mt_entry`\G
    #    SHOW TABLE STATUS FROM `mt1` LIKE 'mt_placement'\G
    #    SHOW CREATE TABLE `mt1`.`mt_placement`\G
    #    SHOW TABLE STATUS FROM `mt1` LIKE 'mt_category'\G
    #    SHOW CREATE TABLE `mt1`.`mt_category`\G
    # EXPLAIN
    SELECT `mt_entry`.`entry_id`, `mt_entry`.`entry_allow_comments`, `mt_entry`.`entry_allow_pings`, `mt_entry`.`entry_atom_id`, `mt_entry`.`entry_author_id`, `mt_entry`.`entry_authored_on`, `mt_entry`.`entry_basename`, `mt_entry`.`entry_blog_id`, `mt_entry`.`entry_category_id`, `mt_entry`.`entry_class`, `mt_entry`.`entry_comment_count`, `mt_entry`.`entry_convert_breaks`, `mt_entry`.`entry_created_by`, `mt_entry`.`entry_created_on`, `mt_entry`.`entry_excerpt`, `mt_entry`.`entry_keywords`, `mt_entry`.`entry_modified_by`, `mt_entry`.`entry_modified_on`, `mt_entry`.`entry_ping_count`, `mt_entry`.`entry_pinged_urls`, `mt_entry`.`entry_status`, `mt_entry`.`entry_tangent_cache`, `mt_entry`.`entry_template_id`, `mt_entry`.`entry_text`, `mt_entry`.`entry_text_more`, `mt_entry`.`entry_title`, `mt_entry`.`entry_to_ping_urls`, `mt_entry`.`entry_week_number` FROM `mt_entry` INNER JOIN `mt_placement` ON (`mt_entry`.`entry_id` = `mt_placement`.`placement_entry_id`) INNER JOIN `mt_category` ON (`mt_placement`.`placement_category_id` = `mt_category`.`category_id`) WHERE (`mt_entry`.`entry_status` = 2  AND `mt_category`.`category_basename` IN ('business_review' /*... omitted 3 items ...*/ ) AND NOT (`mt_entry`.`entry_id` IN (53441))) ORDER BY `mt_entry`.`entry_authored_on` DESC LIMIT 4\G
    
    • 0

相关问题

  • IIS 6.0 (Windows Server 2003) 上的 HTTP 压缩

  • 在 Linux Xen VPS 上优化 Apache 和 MySQL

  • 如何选择 MySQL 数据库引擎

  • 上线的第一天:如何不杀死您的网站

  • IIS 优化

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve