{"id":677,"date":"2019-11-03T01:36:31","date_gmt":"2019-11-02T17:36:31","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=677"},"modified":"2020-08-27T11:34:24","modified_gmt":"2020-08-27T03:34:24","slug":"%e6%9f%a5%e7%9c%8bmysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ae%b9%e9%87%8f%e5%a4%a7%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=677","title":{"rendered":"\u67e5\u770bMySql\u6570\u636e\u5e93\u5bb9\u91cf\u5927\u5c0f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/\/\u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u603b\u5927\u5c0f\nuse information_schema;\nselect concat(round(sum(DATA_LENGTH\/1024\/1024),2),'MB') as data from TABLES;\n+---------+\n| data    |\n+---------+\n| 25.33MB |\n+---------+\n\n\n\/\/\u7edf\u8ba1\u6bcf\u4e2a\u5e93\u5927\u5c0f\nSELECT table_schema,SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)\/1024\/1024 AS total_mb FROM information_schema.TABLES group by table_schema;\n+--------------------+-------------+\n| table_schema       | total_mb    |\n+--------------------+-------------+\n| dbqb               |  0.04687500 |\n| information_schema |        NULL |\n| mysql              |  0.79547882 |\n| performance_schema |  0.00000000 |\n| uwlog              | 24.51486588 |\n+--------------------+-------------+\n\n\/\/\u67e5\u770b\u6240\u6709\u6570\u636e\u5e93\u5404\u5bb9\u91cf\u5927\u5c0f\nselect\ntable_schema as '\u6570\u636e\u5e93',\nsum(table_rows) as '\u8bb0\u5f55\u6570',\nsum(truncate(data_length\/1024\/1024, 2)) as '\u6570\u636e\u5bb9\u91cf(MB)',\nsum(truncate(index_length\/1024\/1024, 2)) as '\u7d22\u5f15\u5bb9\u91cf(MB)'\nfrom information_schema.tables\ngroup by table_schema\norder by sum(data_length) desc, sum(index_length) desc;\n+--------------------+-----------+------------------+------------------+\n| \u6570\u636e\u5e93             | \u8bb0\u5f55\u6570    | \u6570\u636e\u5bb9\u91cf(MB)     | \u7d22\u5f15\u5bb9\u91cf(MB)     |\n+--------------------+-----------+------------------+------------------+\n| uwlog              |      1700 |            24.51 |             0.00 |\n| mysql              |      2553 |             0.70 |             0.03 |\n| dbqb               |         6 |             0.04 |             0.00 |\n| information_schema |      NULL |             0.00 |             0.00 |\n| performance_schema |     74026 |             0.00 |             0.00 |\n+--------------------+-----------+------------------+------------------+<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/677"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=677"}],"version-history":[{"count":1,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/677\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/677\/revisions\/678"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}