Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30635

OPTIMIZE TABLE documentation is not mentioning ANALYZE

    XMLWordPrintable

Details

    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

          Activity

            People

              greenman Ian Gilfillan
              oli Oli Sennhauser
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.