{"id":5823,"date":"2012-11-20T11:49:14","date_gmt":"2012-11-20T09:49:14","guid":{"rendered":"http:\/\/code.openark.org\/blog\/?p=5823"},"modified":"2012-11-20T13:39:03","modified_gmt":"2012-11-20T11:39:03","slug":"state-of-inndb-online-ddl-in-mysql-5-6-8-rc","status":"publish","type":"post","link":"https:\/\/code.openark.org\/blog\/mysql\/state-of-inndb-online-ddl-in-mysql-5-6-8-rc","title":{"rendered":"State of InnDB Online DDL in MySQL 5.6.8-RC"},"content":{"rendered":"<p><strong>5.6.8-rc<\/strong> is out, and so I&#8217;m following up on InnoDB&#8217;s online DDL new feature: the ability to SELECT, INSERT, DELETE, UPDATE a table even while an ALTER TABLE is executing on same table.<\/p>\n<h4>The brief summary<\/h4>\n<p>Not as advertised; many things can&#8217;t be done.<\/p>\n<h4>The longer review<\/h4>\n<p>I&#8217;m using <strong>5.6.8-rc 64bit<\/strong> binary distribution for Linux, installed via <a href=\"http:\/\/mysqlsandbox.net\/\">mysqlsandbox<\/a>. My hardware is irrelevant, but the fact I&#8217;m testing on my laptop assists me in that <strong>ALTER TABLE<\/strong> operations take a while, so that I&#8217;m able to easily type commands in two terminals and have the time to watch them being executed. Query cache is disabled.<!--more--><\/p>\n<p>I&#8217;m using the sakila sample database, and in particular I&#8217;m working with the rental table. Here&#8217;s the table definition:<\/p>\n<blockquote>\n<pre>CREATE TABLE `rental` (\r\n\u00a0 `rental_id` int(11) NOT NULL AUTO_INCREMENT,\r\n\u00a0 `rental_date` datetime NOT NULL,\r\n\u00a0 `inventory_id` mediumint(8) unsigned NOT NULL,\r\n\u00a0 `customer_id` smallint(5) unsigned NOT NULL,\r\n\u00a0 `return_date` datetime DEFAULT NULL,\r\n\u00a0 `staff_id` tinyint(3) unsigned NOT NULL,\r\n\u00a0 `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n\u00a0 PRIMARY KEY (`rental_id`),\r\n\u00a0 UNIQUE KEY `rental_date` (`rental_date`,`inventory_id`,`customer_id`),\r\n\u00a0 KEY `idx_fk_inventory_id` (`inventory_id`),\r\n\u00a0 KEY `idx_fk_customer_id` (`customer_id`),\r\n\u00a0 KEY `idx_fk_staff_id` (`staff_id`),\r\n\u00a0 CONSTRAINT `fk_rental_staff` FOREIGN KEY (`staff_id`) REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE,\r\n\u00a0 CONSTRAINT `fk_rental_inventory` FOREIGN KEY (`inventory_id`) REFERENCES `inventory` (`inventory_id`) ON UPDATE CASCADE,\r\n\u00a0 CONSTRAINT `fk_rental_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE\r\n) ENGINE=InnoDB AUTO_INCREMENT=16050 DEFAULT CHARSET=utf8<\/pre>\n<\/blockquote>\n<p>Highlights for the table: <strong>AUTO_INCREMENT PRIMARY KEY<\/strong>, some columns indexed, some not, and Foreign Keys in place. Pretty much a standard table. It contains <strong>16,044<\/strong> rows. Row format is <strong>COMPACT<\/strong>.<\/p>\n<p>What I want to know is: which DDL commands allow for which online DML commands?<\/p>\n<p>So, on terminal #1 I will issue queries like:<\/p>\n<blockquote>\n<pre>node1 5.6.8-rc-log sakila&gt; alter table <strong>sakila.rental<\/strong> ROW_FORMAT=COMPACT <strong>\/* or whatever *\/<\/strong>;\r\nQuery OK, 0 rows affected (10.57 sec)\r\nRecords: 0\u00a0 Duplicates: 0\u00a0 Warnings: 0<\/pre>\n<\/blockquote>\n<p>And during the above operation, I will execute the following on terminal #2:<\/p>\n<ol>\n<li><strong>select max(rental_id) from sakila.rental;<\/strong> this queries the AUTO_INCREMENT value, which is of course a PRIMARY KEY<\/li>\n<li><strong>select min(rental_date) from sakila.rental<\/strong>; there is an index on rental_date, and normal execution plan is to optimize table away and just use the index<\/li>\n<li><strong>select min(return_date) from sakila.rental<\/strong>; there is no index on return_date, and full table scan is required<\/li>\n<li><strong>update rental set return_date = return_date + interval 1 second where rental_id=3<\/strong>; the UPDATE uses the PRIMARY KEY<\/li>\n<li><strong>update rental set return_date = return_date + interval 1 second where return_date = NOW()<\/strong>; won&#8217;t actually affect anything, but requires full scan.<\/li>\n<\/ol>\n<p>So here are the results:<\/p>\n<blockquote>\n<pre>+-------------------------------------------------------------+-------+---------------------------+---------------+---------------------+-------------------------+--------------+---------------------+\r\n| ALTER statement\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Time\u00a0 | General comments\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | select max PK | select min by index | select min by full scan | update by PK | update by full scan |\r\n+-------------------------------------------------------------+-------+---------------------------+---------------+---------------------+-------------------------+--------------+---------------------+\r\n| ROW_FORMAT=COMPACT\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 10.92 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| AUTO_INCREMENT=16051\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 0.06 | Instant, no table rebuild | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD INDEX(last_update)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 2.37 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD INDEX(last_update), ALGORITHM=INPLACE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 1.83 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD INDEX(last_update), ALGORITHM=INPLACE, LOCK=NONE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 0.00 | ERROR 1235 (42000): ... \u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD COLUMN c CHAR(1) NOT NULL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 11.20 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD COLUMN c CHAR(1) NOT NULL, ALGORITHM=INPLACE, LOCK=NONE |\u00a0 0.00 | ERROR 1235 (42000): .   \u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n+-------------------------------------------------------------+-------+---------------------------+---------------+---------------------+-------------------------+--------------+---------------------+<\/pre>\n<\/blockquote>\n<p>Rather surprising, I would say.<\/p>\n<ul>\n<li><em>None<\/em> of my tests resolved with online write (<strong>UPDATE<\/strong>). At best I could get online read (<strong>SEELCT<\/strong>).<br \/>\n<strong><\/strong><\/li>\n<li><strong>AUTO_INCREMENT<\/strong> is instantaneous. High time for that! It&#8217;s just some number in the <strong>.frm<\/strong> file, never understood the need for table rebuild.<\/li>\n<li>Apparently <strong>ADD COLUMN<\/strong> is <em>more online<\/em> than <strong>ADD INDEX<\/strong>, and I&#8217;ve tested this again and again and again to make sure I was doing it right. This is quite weird, even according to the <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/innodb-online-ddl.html\">docs<\/a>.<\/li>\n<li>In none of the above tests (and others, non listed), have I been able to specify <strong>LOCK=NONE<\/strong>. It&#8217;s always <strong>ERROR 1235 (42000): This version of MySQL doesn&#8217;t yet support &#8216;alter table sakila.rental &lt;whatever&gt;, algorithm=inplace, lock=none&#8217;<\/strong>.<\/li>\n<\/ul>\n<p>So what&#8217;s so online about this? Online reads are nice, but most everyone cannot accept blocking writes (for same reason no one would use <em>mysqlhotcopy<\/em>, also so wrongly named). This leaves us again with <a href=\"http:\/\/openarkkit.googlecode.com\/svn\/trunk\/openarkkit\/doc\/html\/oak-online-alter-table.html\">oak-online-alter-table<\/a> and <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.1\/pt-online-schema-change.html\">pt-online-schema-change<\/a>.<\/p>\n<h4>The butler did it<\/h4>\n<p>Apologies to the butler, the <strong>FOREIGN KEY<\/strong>s did it. Let&#8217;s try the same again without foreign keys:<\/p>\n<blockquote>\n<pre>node1 5.6.8-rc-log sakila&gt; create table rental2 like rental;\r\nnode1 5.6.8-rc-log sakila&gt; insert into rental2 select * from rental;\r\nnode1 5.6.8-rc-log sakila&gt; rename table rental to rental_old, rental2 to rental;\r\nQuery OK, 0 rows affected (0.31 sec)<\/pre>\n<\/blockquote>\n<p>Here are the results:<\/p>\n<blockquote>\n<pre>+-------------------------------------------------------------+-------+---------------------------+----------------+---------------------+-------------------------+----------------+---------------------+\r\n| ALTER statement\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Time  | General comments\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | select max PK\u00a0 | select min by index | select min by full scan | update by PK\u00a0\u00a0 | update by full scan |\r\n+-------------------------------------------------------------+-------+---------------------------+----------------+---------------------+-------------------------+----------------+---------------------+\r\n| ROW_FORMAT=COMPACT\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 11.03 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #008000;\">Instant<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| AUTO_INCREMENT=16051\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 0.05 | Instant, no table rebuild | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | N\/A\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD INDEX(last_update)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 2.04 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD INDEX(last_update), ALGORITHM=INPLACE, LOCK=NONE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 3.14 |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | <span style=\"color: #800000;\">blocked<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD COLUMN c CHAR(1) NOT NULL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0   ** |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n| ADD COLUMN c CHAR(1) NOT NULL, ALGORITHM=INPLACE, LOCK=NONE |\u00a0\u00a0\u00a0 ** |\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | * <span style=\"color: #ff6600;\">Inconsistent<\/span> | * <span style=\"color: #ff6600;\">Inconsistent<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0 |\r\n+-------------------------------------------------------------+-------+---------------------------+----------------+---------------------+-------------------------+----------------+---------------------+<\/pre>\n<\/blockquote>\n<p>What&#8217;s going on here?<\/p>\n<ul>\n<li><strong>ALGORITHM=INPLACE, LOCK=NONE<\/strong> is accepted! Bad, bad foreign keys!<br \/>\n<strong><\/strong><\/li>\n<li><strong>* ADD INDEX<\/strong> usually allows for concurrent reads, but after repeated tests <strong>SELECT<\/strong>s start to block. Then they don&#8217;t work concurrently anymore until table is recreated. But even that not always, so I&#8217;m not sure what the inconsistency is.<\/li>\n<li><strong>* ADD COLUMN<\/strong> is still more concurrent than <strong>ADD INDEX<\/strong>, and actually allows for concurrent writes! Though, inconsistently. Sometimes it does not allow for concurrent writes.<\/li>\n<li><strong>** ADD COLUMN<\/strong> runtime highly affected by concurrent queries. It wents as high as <strong>45<\/strong> seconds on my laptop. Now, to make things clear, I&#8217;m not running an automated benchmark here: I&#8217;m copying+pasting the statements from my editor to the mysql CLI. So, maybe <strong>10<\/strong> or <strong>15<\/strong><strong>SELECT<\/strong> and <strong>UPDATE<\/strong> queries executes. How does that justify <strong>35<\/strong> seconds delay in table rebuild?<\/li>\n<\/ul>\n<h4>Some conclusions:<\/h4>\n<ul>\n<li>The documentation does not specify anything about <strong>FOREIGN KEY<\/strong>s crashing the party. It should.<\/li>\n<li>The documentation specifically mentions the <strong>ADD\/DROP INDEX<\/strong> statements to be online. <strong>ADD INDEX<\/strong> is less online than <strong>ADD COLUMN<\/strong>.<\/li>\n<li>Everything is still shaky. Sometimes things work, sometimes they don&#8217;t.<\/li>\n<li>Runtimes are unproportionally affected by concurrent queries.<\/li>\n<li>For the meantime, I keep to my online alter table scripts. Been using them for <strong>3.5<\/strong> years now.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>5.6.8-rc is out, and so I&#8217;m following up on InnoDB&#8217;s online DDL new feature: the ability to SELECT, INSERT, DELETE, UPDATE a table even while an ALTER TABLE is executing on same table. The brief summary Not as advertised; many things can&#8217;t be done. The longer review I&#8217;m using 5.6.8-rc 64bit binary distribution for Linux, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[14,89,34,94],"class_list":["post-5823","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-innodb","tag-new-features","tag-openark-kit","tag-review"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bZZp-1vV","_links":{"self":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/5823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/comments?post=5823"}],"version-history":[{"count":14,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/5823\/revisions"}],"predecessor-version":[{"id":5836,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/5823\/revisions\/5836"}],"wp:attachment":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/media?parent=5823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/categories?post=5823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/tags?post=5823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}