[WordPress] 資料庫太肥大 清理 wp_options table


這裡記錄清理資料庫 wp_options 的過程


https://syuanme.blogspot.com/

先看一下 wp_options 裡面到底有多少資料
mysql> select count(*) from wp_options;

紀錄這個大概架了一年的網站

508949 筆資料在 table 裡


接著執行清理指令

把資料表中有 _transient 的紀錄都刪除

mysql> DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%');
刪除完成剩下 718 筆紀錄


_transient 是 wordpress 和一些 plugin 用來暫存資料庫的複雜查詢紀錄的

通常會自動刪除過期的紀錄

可以看第一張圖

option_id 都五百多萬了但是總共資料只有五十萬筆

不過還是可能會有漏刪的情況

也許是搬家、也許是刪除停用 plugin、也許是伺服器暫時錯誤等等

所以偶爾想到還是清理一下吧~


https://syuanme.blogspot.com/
reference:
https://stackoverflow.com/questions/10422574/can-i-remove-transients-in-the-wp-options-table-of-my-wordpress-install
https://crunchify.com/what-are-transient-entries-in-wp-options-table-transient-buildup-information/

留言

張貼留言

熱門文章