国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

Mysql的表的碎片清理_MySQL

來源:懂視網 責編:小采 時間:2020-11-09 20:06:56
文檔

Mysql的表的碎片清理_MySQL

Mysql的表的碎片清理_MySQL:最近在生成環境下的mysql運行下降,有些sql執行也慢,首先檢查下慢查詢日志是否開啟 show variables like ‘slow_query_log%’ 在看慢日志設置的時間 show variables like ‘long_query_time%’;
推薦度:
導讀Mysql的表的碎片清理_MySQL:最近在生成環境下的mysql運行下降,有些sql執行也慢,首先檢查下慢查詢日志是否開啟 show variables like ‘slow_query_log%’ 在看慢日志設置的時間 show variables like ‘long_query_time%’;
最近在生成環境下的mysql運行下降,有些sql執行也慢,首先檢查下慢查詢日志是否開啟
show variables like ‘slow_query_log%’
第一張圖
在看慢日志設置的時間
show variables like ‘long_query_time%’;
第二張圖
可以看到開啟了慢查詢,find / -name slow-query.log查找慢日志
發現里面的sql是很慢但是都走了索引但是這些慢的sql都指向一兩個表。所以想到可能是每次備份對這幾個表的刪除操作,但是沒有進行碎片整理
進行下碎片整理,按表的引擎來處理
Myisam清理碎片
OPTIMIZE TABLE table_name、
InnoDB碎片清理
看到這段話
if you frequently delete rows (or update rows with variable-length data types), you can end up with a lot of wasted space in your data file(s), similar to filesystem fragmentation.
If you’re not using the innodb_file_per_table option, the only thing you can do about it is export and import the database, a time-and-disk-intensive procedure.
But if you are using innodb_file_per_table, you can identify and reclaim this space!
Prior to 5.1.21, the free space counter is available from the table_comment column of information_schema.tables. Here is some SQL to identify tables with at least 100M (actually 97.65M) of free space:
SELECT table_schema, table_name, table_comment FROM information_schema.tables WHERE engine LIKE ‘InnoDB’ AND table_comment RLIKE ‘InnoDB free: ([0-9]{6,}).*’;
Starting with 5.1.21, this was moved to the data_free column (a much more appropriate place):
SELECT table_schema, table_name, data_free/1024/1024 AS data_free_MB FROM information_schema.tables WHERE engine LIKE ‘InnoDB’ AND data_free > 100*1024*1024;
You can reclaim the lost space by rebuilding the table. The best way to do this is using ‘alter table’ without actually changing anything:
ALTER TABLE foo ENGINE=InnoDB;
This is what MySQL does behind the scenes if you run ‘optimize table’ on an InnoDB table. It will result in a read lock, but not a full table lock. How long it takes is completely dependent on the amount of data in the table (but not the size of the data file). If you have a table with a high volume of deletes or updates, you may want to run this monthly, or even weekly.
所以先進行分析,語句如下
SELECT table_schema, table_name, data_free/1024/1024 AS data_free_MB FROM information_schema.tables WHERE engine LIKE ‘InnoDB’ AND data_free > 100*1024*1024;
返回了兩個數據,正是那兩張表得data_free大于100M,所以ALTER TABLE tablename ENGINE=InnoDB;
相當于重建表引擎了。再執行速度正常了。
這里要提下如果一個表的表數據大小和索引大小與實際的表數據不符也需要清理下表碎片

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

Mysql的表的碎片清理_MySQL

Mysql的表的碎片清理_MySQL:最近在生成環境下的mysql運行下降,有些sql執行也慢,首先檢查下慢查詢日志是否開啟 show variables like ‘slow_query_log%’ 在看慢日志設置的時間 show variables like ‘long_query_time%’;
推薦度:
標簽: 清理 碎片 mysql
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 国产精品一区在线观看 | 一区不卡在线观看 | 国产精品久久久久… | 日韩欧美精品 | 欧美激情视频一区二区 | 碰91精品国产91久久婷婷 | 日韩 亚洲 欧美 中文 高清 | 国产精品久久久久久久久 | 国产中文久久精品 | 欧美日韩精品一区二区三区视频在线 | 91久久九九精品国产综合 | 婷婷久草 | 精品一区二区三区的国产在线观看 | 一级一级特黄女人精品毛片视频 | 国产成人精品一区二三区在线观看 | 久久成人a毛片免费观看网站 | 国产精品视频久久久久久 | 精品国产免费一区二区三区五区 | 国产精品免费观看视频 | 欧美综合自拍亚洲综合 | 久久国产精品自由自在 | 国产精品免费视频播放 | 一区二区国产在线观看 | 免费看黄色毛片 | 久久91精品国产一区二区 | 国产1区2区 | 国内一级野外a一级毛片 | 成人国产精品免费网站 | 黄a毛片 | 久久国产精品成人免费 | 亲子交尾五十路 | 日韩精品第1页 | 亚韩在线 | 亚洲视频在线观看视频 | 亚洲日韩欧美视频 | 亚洲精品123区 | 国产精品高清一区二区 | 国产综合一区二区 | 国产精品免费观看网站 | 日韩不卡一区二区三区 | 成人国产一区 |