Bug #76731 The restriction for same index name drop/add in one line is wrong for MySQL 5.6.
Submitted: 17 Apr 2015 9:38 Modified: 27 Apr 2015 11:52
Reporter: Meiji Kimura Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: CPU Architecture:Any

[17 Apr 2015 9:38] Meiji Kimura
Description:
In the below manual page,

http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-limitations.html

describe about 'An ALTER TABLE statement that contains DROP INDEX and ADD INDEX clauses that both name the same index uses a table copy, not Fast Index Creation. '

But now MySQL(InnoDB) can such an operation in place (as Online DDL).

ALTER TABLE revision drop index tmp_index2, add index tmp_index2(mycol,v2,i1), algorithm=inplace, LOCK=NONE;
Query OK, 0 rows affected (6.31 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql [localhost] {msandbox} (test) > select @@version;
+---------------------------------------+
| @@version                             |
+---------------------------------------+
| 5.6.11-enterprise-commercial-advanced |
+---------------------------------------+
1 row in set (0.00 sec)

How to repeat:
(1) prepare DDL & SP for Dummy data.

DROP TABLE IF EXISTS revision;
CREATE TABLE revision(i1 int not null primary key, v2 varchar(20)) engine = innodb;

drop procedure if exists make_revision_data;
delimiter $
create procedure make_revision_data(v_max int)
begin
    declare v_id int default 0;
    repeat
        set v_id = v_id + 1;
        insert into revision values(v_id, v_id);
        if (mod(v_id,10000) = 0) then commit;
        end if;
    until v_id >= v_max
    end repeat;
end$
delimiter ;

(2) Make dummy data

set autocommit=0;
call make_revision_data(1000000);

(3) Add an index

ALTER TABLE revision add index tmp_index2(v2,i1); 

(4) Drop/Add an index

ALTER TABLE revision drop index tmp_index2, add index tmp_index2(i1,v2), algorithm=inplace, LOCK=NONE;

It can run and take 6 or 7 seconds. 

If the alter table with algorithm=copy, it will take 20-seconds or moer.

Suggested fix:
Remove that limitation on MySQL 5.6 manual.
[17 Apr 2015 10:09] MySQL Verification Team
Hello Meiji-San,

Thank you for the report.

Thanks,
Umesh
[27 Apr 2015 11:52] Daniel Price
Posted by developer:
 
The restriction has been removed from the InnoDB online DDL documentation in the MySQL 5.6 and 5.7 reference manual. 

Thank you for the bug report.