国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

mysql增加了表格字段,結果表格數據體積減小了?

瀏覽:87日期:2022-06-15 17:28:55

問題描述

發現了兩個需要新存儲的字段,就通過alter add添加了兩個字段,一個int, 一個float,結果發現變更完之后表格占用的體積反而減少了。

變更前:43個字段,14個索引字段,8141516 kb;變更后:45個字段,14個索引字段,8120649 kb;數據表大約226w條數據,myisam引擎,新添加的兩個字段里面尚未寫入數據,但減少了大約20M。

是因為在做數據表變更時同時做了優化、壓縮之類的操作嗎?

問題解答

回答1:

alter table在大部分情況下,會對原來的表生成一個臨時的副本(臨時表)。然后更新會進行到這個臨時表里,創建一個新的表,刪除原來的表。所以可以通過alter table 來優化表空間,修復操作產生的碎片空間。所以表空間變小了。我描述的可能不是很好,官方文檔原話是這樣子的

In most cases, ALTER TABLE makes a temporary copy of the original table. MySQL waits for other operations that are modifying the table, then proceeds. It incorporates the alteration into the copy, deletes the original table, and renames the new one. While ALTER TABLE is executing, the original table is readable by other sessions (with the exception noted shortly). Updates and writes to the table that begin after the ALTER TABLE operation begins are stalled until the new table is ready, then are automatically redirected to the new table without any failed updates. The temporary copy of the original table is created in the database directory of the new table. This can differ from the database directory of the original table for ALTER TABLE operations that rename the table to a different database.

具體官方文檔鏈接可以參考https://dev.mysql.com/doc/ref...

PS: 可以看文檔下面的comments,有人說到

You can use Alter Table to optimise a table without locking outselects (only writes), by altering a column to be the same as it’scurrent definition. This is better than using repair table whichobtains a read/write lock.

截個圖

mysql增加了表格字段,結果表格數據體積減小了?

主站蜘蛛池模板: 国产剧情一区二区 | 91精品国产一区二区三区左线 | 成人黄色一级视频 | 2018av男人天堂 | 亚洲美女黄色片 | 国产深夜福利视频网站在线观看 | 国产农村乱 | 亚洲一区二区视频 | 国内亚州视频在线观看 | 在线观看精品自拍视频 | 国产美女做爰免费视频网址 | 欧洲免费无线码二区5 | 在线成年人网站 | 国产高清在线观看视频手机版 | 亚洲黄a | 国产亚洲精品线观看77 | 久艹在线观看 | 日韩在线视频免费 | 日本丶国产丶欧美色综合 | 国产中文字幕免费观看 | 欧美一区二区三区免费高 | 成人一级黄色片 | 国产一区二区三区亚洲欧美 | 97视频免费上传播放 | 日韩欧美一区二区三区免费看 | 另类亚洲孕妇分娩网址 | 特色一级片 | 欧美成人观看免费完全 | 欧美日本韩国一区 | 在线视频 自拍 | 国产大片线上免费看 | 河边性xxxxfreexxxxx | 成人18免费入口 | 二区在线观看 | 亚洲不卡一区二区三区在线 | 91精品国产综合久久香蕉 | 久久久青青久久国产精品 | 久久综合九九亚洲一区 | 一级全免费视频播放 | 亚洲精品一区二区手机在线 | 农村寡妇野外情一级毛片 |