Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Fix
Description
Documentation of OPTIMIZE TABLE does NOT mention that this command also does an implicit ANALYZE TABLE.
If we look at the command output this seems to be the case:
SQL> OPTIMIZE TABLE test; |
+-----------+----------+----------+-------------------------------------------------------------------+ |
| Table | Op | Msg_type | Msg_text | |
+-----------+----------+----------+-------------------------------------------------------------------+ |
| test.test | optimize | note | Table does not support optimize, doing recreate + analyze instead | |
| test.test | optimize | status | OK |
|
+-----------+----------+----------+-------------------------------------------------------------------+ |
Also looking at the code points to this behaviour:
sql/sql_admin.cc |
static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, |
...
|
case HA_ADMIN_TRY_ALTER: |
{
|
Alter_info *alter_info= &lex->alter_info;
|
 |
protocol->store(STRING_WITH_LEN("note"), system_charset_info); |
if (alter_info->partition_flags & ALTER_PARTITION_ADMIN) |
{
|
protocol->store(STRING_WITH_LEN(
|
"Table does not support optimize on partitions. All partitions " |
"will be rebuilt and analyzed."),system_charset_info); |
}
|
else |
{
|
protocol->store(STRING_WITH_LEN(
|
"Table does not support optimize, doing recreate + analyze instead"), |
system_charset_info);
|
}
|
Attachments
Issue Links
- relates to
-
MDEV-18385 Document use cases and locking behavior for OPTIMIZE TABLE with innodb_defragment=1
- Open