码迷,mamicode.com
首页 > 数据库 > 详细

Database Administration Statements

时间:2018-04-18 23:41:54      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:删除   min   tor   操作系统   imp   插入   nbsp   statement   执行   

MySQL 5.5 Reference Manual  /  

 

optimize table

mysql> ? optimize table
Name: ‘OPTIMIZE TABLE‘
Description:
Syntax:
OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_name] ...

NO_WRITE_TO_BINLOG 抑制sql语句被写入到binlog

Reorganizes the physical storage of table data and associated index data, to reduce storage space and improve I/O efficiency when accessing the table. The exact changes made to each table depend on the storage engine used by that table.
重新组织表数据和相关索引数据的物理存储,减少存储空间、提升访问表时的I/O效率,对每张表的确切的改变取决于该表使用的存储引擎。

Use OPTIMIZE TABLE in these cases, depending on the type of table:
在这些场景下优化表,取决于表类型:
o After doing substantial insert, update, or delete operations on an InnoDB table that has its own .ibd file because it was created with the innodb_file_per_table option enabled. The table and indexes are reorganized, and disk space can be reclaimed for use by the operating
system.
o 在一张有自己的.ibd文件的InnoDB表(创建时启用innodb_file_per_table选项)执行了大量的插入、更新或删除操作之后,
通过执行optimize table,这个表会被重新组织,磁盘空间可以被操作系统再次使用。(聚簇索引)

o After deleting a large part of a MyISAM or ARCHIVE table, or making many changes to a MyISAM or ARCHIVE table with variable-length rows (tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns). Deleted rows are maintained in a linked list and subsequent INSERT operations reuse old row positions. You can use OPTIMIZE TABLE to reclaim the unused space and to defragment the data file. After extensive changes to a table, this statement may also improve performance of statements that use the table, sometimes significantly.
o 在删除了一个MyISAM或ARCHIVE表的一大部分、或对包含可变长度行的MyISAM ARCHIVE表(包含VARCHAR VARBINARY BLOB TEXT列的表)做了很多改变,
被删除的行通过一个linked list来维护,随后的插入操作重新使用旧的行位置。你可以使用OPTIMIZE TABLE 来收回未使用的空间、对数据文件碎片整理。
在大量的改变之后,这个语句也可以显著提升使用这张表的语句的性能。
This statement requires SELECT and INSERT privileges for the table.
这个语句要求具有对该表的select和insert权限。

OPTIMIZE TABLE is also supported for partitioned tables. For information about using this statement with partitioned tables and table partitions, see
http://dev.mysql.com/doc/refman/5.5/en/partitioning-maintenance.html.

URL: http://dev.mysql.com/doc/refman/5.5/en/optimize-table.html

OPTIMIZE TABLE 也支持分区表。

Database Administration Statements

标签:删除   min   tor   操作系统   imp   插入   nbsp   statement   执行   

原文地址:https://www.cnblogs.com/zhengwenqiang/p/8878040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!