mysql索引 - MySQL:索引是否需要整理維護?
問題描述
每月定期需要對數據進行大量的刪除操作,想請教這樣操作后對索引是否有影響,是否需要在刪除操作完成后對索引進行更新之類的操作
如果需要的話這方面的內容搜索哪些關鍵字呢?
問題解答
回答1:可以使用OPTIMIZE定期優化表,每個星期或者每個月一次,具體可以參考下面鏈接http://dev.mysql.com/doc/refm...
摘自官網的描述
Use OPTIMIZE TABLE in these cases, depending on the type of table:
After doing substantial insert, update, or delete operations on anInnoDB table that has its own .ibd file because it was created withthe innodb_file_per_table option enabled. The table and indexes arereorganized, and disk space can be reclaimed for use by the operatingsystem.
After doing substantial insert, update, or delete operations oncolumns that are part of a FULLTEXT index in an InnoDB table. Set theconfiguration option innodb_optimize_fulltext_only=1 first. To keepthe index maintenance period to a reasonable time, set theinnodb_ft_num_word_optimize option to specify how many words to updatein the search index, and run a sequence of OPTIMIZE TABLE statementsuntil the search index is fully updated.
After deleting a large part of a MyISAM or ARCHIVE table, or makingmany changes to a MyISAM or ARCHIVE table with variable-length rows(tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns). Deletedrows are maintained in a linked list and subsequent INSERT operationsreuse old row positions. You can use OPTIMIZE TABLE to reclaim theunused space and to defragment the data file. After extensive changesto a table, this statement may also improve performance of statementsthat use the table, sometimes significantly.
相關文章:
1. macos - mac下docker如何設置代理2. angular.js - ng-grid 和tabset一起用時,grid width默認特別小3. apache - 本地搭建wordpress權限問題4. 熱切期待朱老師的回復,網頁視頻在線播放器插件配置錯誤5. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????6. java - Spring Mvc全局異常處理器@ControllerAdvice不起作用?7. Whitelabel錯誤頁面發生意外錯誤(類型=未找到,狀態= 404)/WEB-INF/views/home.jsp8. javascript - web網頁版app返回上一頁按鈕在ios設備失效怎么辦?安卓上可以,代碼如下,請大神幫助,萬分感謝。9. Android下,rxJava+retrofit 并發上傳文件和串行上傳文件的效率為什么差不多?10. css3 - transition屬性當鼠標一開的時候設置的時間不起作用
