{"id":1477,"date":"2024-09-14T15:43:57","date_gmt":"2024-09-14T07:43:57","guid":{"rendered":"https:\/\/blog.nonot.cn\/?p=1477"},"modified":"2024-09-14T15:43:57","modified_gmt":"2024-09-14T07:43:57","slug":"mysql%e6%9f%a5%e7%9c%8b%e6%95%b0%e6%8d%ae%e5%ba%93%e8%a1%a8%e5%ae%b9%e9%87%8f%e5%a4%a7%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2024\/09\/14\/mysql%e6%9f%a5%e7%9c%8b%e6%95%b0%e6%8d%ae%e5%ba%93%e8%a1%a8%e5%ae%b9%e9%87%8f%e5%a4%a7%e5%b0%8f\/","title":{"rendered":"Mysql\u67e5\u770b\u6570\u636e\u5e93\u8868\u5bb9\u91cf\u5927\u5c0f"},"content":{"rendered":"<div>\u5355\u8868\u884c\u6570\u8d85\u8fc7 500 \u4e07\u884c\u6216\u8005\u5355\u8868\u5bb9\u91cf\u8d85\u8fc7 2GB\uff0c\u624d\u63a8\u8350\u8fdb\u884c\u5206\u5e93\u5206\u8868\u3002<\/div>\n<div>\u8bf4\u660e\uff1a\u5982\u679c\u9884\u8ba1\u4e09\u5e74\u540e\u7684\u6570\u636e\u91cf\u6839\u672c\u8fbe\u4e0d\u5230\u8fd9\u4e2a\u7ea7\u522b\uff0c\u8bf7\u4e0d\u8981\u5728\u521b\u5efa\u8868\u65f6\u5c31\u5206\u5e93\u5206\u8868\u3002<\/div>\n<div><\/div>\n<div>1. \u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8bb0\u5f55\u6570\u548c\u5bb9\u91cf<\/div>\n<div>SELECT<\/div>\n<div>table_schema AS &#8216;\u6570\u636e\u5e93&#8217;,<\/div>\n<div>SUM(table_rows) AS &#8216;\u8bb0\u5f55\u6570&#8217;,<\/div>\n<div>SUM(TRUNCATE(data_length\/1024\/1024, 2)) AS &#8216;\u6570\u636e\u5bb9\u91cf(MB)&#8217;,<\/div>\n<div>SUM(TRUNCATE(index_length\/1024\/1024, 2)) AS &#8216;\u7d22\u5f15\u5bb9\u91cf(MB)&#8217;<\/div>\n<div>FROM information_schema.tables<\/div>\n<div>GROUP BY table_schema<\/div>\n<div>ORDER BY SUM(data_length) DESC, SUM(index_length) DESC;<\/div>\n<div><\/div>\n<div>2. \u67e5\u8be2\u6307\u5b9a\u6570\u636e\u5e93\u8bb0\u5f55\u6570\u548c\u5bb9\u91cf<\/div>\n<div>SELECT<\/div>\n<div>table_schema AS &#8216;\u6570\u636e\u5e93&#8217;,<\/div>\n<div>SUM( table_rows ) AS &#8216;\u8bb0\u5f55\u6570&#8217;,<\/div>\n<div>SUM(TRUNCATE ( data_length \/ 1024 \/ 1024, 2 )) AS &#8216;\u6570\u636e\u5bb9\u91cf(MB)&#8217;,<\/div>\n<div>SUM(TRUNCATE ( index_length \/ 1024 \/ 1024, 2 )) AS &#8216;\u7d22\u5f15\u5bb9\u91cf(MB)&#8217;<\/div>\n<div>FROM information_schema.TABLES<\/div>\n<div>WHERE table_schema = &#8216;syspt&#8217;;<\/div>\n<div><\/div>\n<div>3\u3001\u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u6bcf\u4e2a\u8868\u7684\u8bb0\u5f55\u6570\u548c\u5bb9\u91cf<\/div>\n<div>SELECT<\/div>\n<div>table_schema AS &#8216;\u6570\u636e\u5e93&#8217;,<\/div>\n<div>table_name AS &#8216;\u8868\u540d&#8217;,<\/div>\n<div>table_rows AS &#8216;\u8bb0\u5f55\u6570&#8217;,<\/div>\n<div>TRUNCATE(data_length\/1024\/1024, 2) AS &#8216;\u6570\u636e\u5bb9\u91cf(MB)&#8217;,<\/div>\n<div>TRUNCATE(index_length\/1024\/1024, 2) AS &#8216;\u7d22\u5f15\u5bb9\u91cf(MB)&#8217;<\/div>\n<div>FROM information_schema.tables<\/div>\n<div>ORDER BY data_length DESC, index_length DESC;<\/div>\n<div><\/div>\n<div>4. \u67e5\u8be2\u6307\u5b9a\u6570\u636e\u5e93\u6bcf\u4e2a\u8868\u7684\u8bb0\u5f55\u6570\u548c\u5bb9\u91cf<\/div>\n<div>SELECT<\/div>\n<div>table_schema AS &#8216;\u6570\u636e\u5e93&#8217;,<\/div>\n<div>table_name AS &#8216;\u8868\u540d&#8217;,<\/div>\n<div>table_rows AS &#8216;\u8bb0\u5f55\u6570&#8217;,<\/div>\n<div>TRUNCATE(data_length\/1024\/1024, 2) AS &#8216;\u6570\u636e\u5bb9\u91cf(MB)&#8217;,<\/div>\n<div>TRUNCATE(index_length\/1024\/1024, 2) AS &#8216;\u7d22\u5f15\u5bb9\u91cf(MB)&#8217;<\/div>\n<div>FROM information_schema.tables<\/div>\n<div>WHERE table_schema=&#8217;syspt&#8217;<\/div>\n<div>ORDER BY data_length DESC, index_length DESC;<\/div>\n<div><\/div>\n<div>5. \u7edf\u8ba1\u6240\u6709\u6570\u636e\u5e93\u7684\u603b\u5927\u5c0f<\/div>\n<div>SELECT CONCAT(ROUND(SUM(DATA_LENGTH\/1024\/1024),2),&#8217;MB&#8217;) AS DATA FROM information_schema.TABLES;<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5355\u8868\u884c\u6570\u8d85\u8fc7 500 \u4e07\u884c\u6216\u8005\u5355\u8868\u5bb9\u91cf\u8d85\u8fc7 2GB\uff0c\u624d\u63a8\u8350\u8fdb&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1477","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1477"}],"version-history":[{"count":1,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1477\/revisions"}],"predecessor-version":[{"id":1478,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1477\/revisions\/1478"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}