June 19, 2013

Post: pt-online-schema-change and default values

alter=”add column v varchar(100) not null” D=sbtest,t=sbtest Altering `sbtest`.`sbtest`… Creating new table… Created new table sbtest._sbtest_new OK. Altering

Post: Hacking to make ALTER TABLE online for certain changes

… auto_increment from 100G table. No matter if it’s InnoDB or MyISAM, you’d usually ALTER TABLE `huge_table` CHANGE `id` `id` int… auto_incremental from the table. As a rule of thumb, this usually involves altering huge InnoDB tables and huge tables take time to rebuild… auto_increment does not work that way. Enum values (add and remove). Enumerated values are added and removed the same way that auto…

Post: High-Performance Click Analysis with MySQL

…or two capabilities you absolutely need now; then add the rest later, reloading the data if needed…’t save you from the downtime caused by ALTER TABLE — a typical reason to think about master-…has a custom table, which is really constructed behind the scenes from the name-value tables in a complex…

Post: Picking datatype for STATUS fields

… efficient. The problem with ENUM is adding new values using traditional way (ALTER TABLE) causes table rebuild which is not acceptable for many environments… order in which values are specified in the ENUM declaration – not according to their string values. So make sure to add values specify strings…

Post: Full table scan vs full index scan performance

… take the employees database, and slightly modify the employees tables: mysql> ALTER TABLE employees ADD INDEX idx_first (first_name),ENGINE=InnoDB; And then… then lots of random reads to fetch rows by index value. And random reads are orders of magnitude slower than sequential…. Here if we know that the table will always be in memory, we should add the FORCE INDEX hint to ensure optimal…

Post: Extending Index for Innodb tables can hurt performance in a surprising way

… are special cases when this is not the case. CREATE TABLE `idxitest` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `a… hurt any other queries a lot, right ? mysql> alter table idxitest drop key a,add key(a,b); Query OK, 0 rows affected… entries being sorted by primary key for each complete key value. So when you have index (a) and id is a…

Post: InnoDB Full-text Search in MySQL 5.6 (part 1)

… I create one, the following warning is generated: mysql> alter table dir_test_innodb ADD FULLTEXT KEY (full_name, details); Query OK, 0… you defined for the underlying table, or it can be a sequence value generated by InnoDB when the table does not contain a… it, this is what happens: mysql> alter table dir_test_innodb ADD FULLTEXT KEY (full_name, details), ADD FULLTEXT KEY (details); ERROR 1795 (HY000…

Post: Knowing what pt-online-schema-change will do

…INTO `test`.`_t_new` (`id`, `guest_language`, `guest_country`, `score`) VALUES (NEW.`id`, NEW.`guest_language`, NEW.`guest_country`, NEW.`…the –alter statement: Altering new tableALTER TABLE `test`.`_t_new` add column (foo char(2)) Altered `test`.`_t_new` OK. If the syntax of the –alter

Post: Improved InnoDB fast index creation

… rows affected (0.00 sec) mysql> INSERT INTO t(c) VALUES (RAND()); Query OK, 1 row affected (0.00 sec) mysql… table makes any difference: mysql> SET expand_fast_index_creation=OFF; Query OK, 0 rows affected (0.00 sec) mysql> ALTER TABLE t ADD KEY (c), ADD KEY(c); Query OK, 0 rows affected (36.42 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE