June 18, 2013

Post: The small improvements of MySQL 5.6: Duplicate Index Detection

…in MySQL 5.5, you will succeed without errors or warnings: mysql> ALTER TABLE test ADD INDEX (… # ######################################################################## # Key redundant ends with a prefix of the clustered index # Key definitions: # KEY `redundant` (`col2`,`id`) # PRIMARY KEY (`id`),…

Post: MySQL Query Patterns, Optimized - Webinar questions followup

… gave a presentation on “MySQL Query Patterns, Optimized” for Percona MySQL Webinars.  If you missed it, you… in a suboptimal form. Q: Doesn’t the primary key solution for random selection only work when the…better random choice. Another workaround may be to add a column to the table, and populate the…

Post: Is Synchronous Replication right for your app?

… Innodb is a single row (well, the PRIMARY KEY index entry for that row).  This means…standard MySQL replication from this instance, since MySQL replication is asynchronous. What about semi-sync MySQL replication?…joins a group, you run a transaction that adds the relationship row to users_groups, but…

Post: MySQL Indexing Best Practices: Webinar Questions Followup

… make primary key significantly fragmented. I also would note there are some MySQL optimizer restrictions in how well it can deal with primary key appended… will need to add indexes manually. Q: What are some methods to overcome vastly differing cardinality on a primary key. After running an…

Post: Long PRIMARY KEY for Innodb tables

key will refer to the rows by primary key. I also recommended to use sequential primary keys so you do not end up having random primary key… MyISAM tables in case of MySQL/System crash is painful and great to be avoided. Long primary key – why did not I use… also wanted to keep system flexible so if we want add more thumbnail sizes we would not need to change anything…

Post: Hijacking Innodb Foreign Keys

… back to HardCore MySQL business – foreign Keys. MySQL supported Foreign Keys for Innodb for many years, yet rudimentary support initially added in MySQL 3.23… foreign keys to make it happen: CREATE TABLE `parent` ( `parent_id` int(11) NOT NULL, `v` varchar(10) DEFAULT NULL, PRIMARY KEY (`parent… mysql> update child set parent_id=1 and v=’BBB’; ERROR 1452 (23000): Cannot add or update a child row: a foreign key

Post: Find and remove duplicate indexes

add index(name); mysql> alter table t add index(name); mysql> alter table t add index(name); mysql> show create table t\G [...] KEY `name` (`name`), KEY…secondary keys contains the primary key column. Let’s see the following example: mysql> show create table t; [...] PRIMARY KEY (`i`), KEY `key_name`…

Post: Multi Range Read (MRR) in MySQL 5.6 and MariaDB 5.5

… the primary key values, and then instead of point primary key lookups, a range lookup is performed on the primary key by using the sorted primary key values…: SELECT key_column, pk_column FROM tbl WHERE key_column=x ORDER BY key_column (Note that secondary keys in InnoDB contain primary key columns) Buffer… fact MRR adds extra sorting overhead which means that the queries are just a bit slower as compared to MySQL 5.5…

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

… NULL, `full_name` varchar(100) DEFAULT NULL, `details` text, PRIMARY KEY (`id`), FULLTEXT KEY `full_name` (`full_name`,`details`) ) ENGINE=InnoDB DEFAULT CHARSET… InnoDB need to add a hidden column (similar to GEN_CLUST_INDEX when you don’t define a PRIMARY KEY, I assume) when… get an error: mysql> CREATE TABLE dir_test_innodb4 (fts_doc_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); ERROR 1166 (42000…