June 19, 2013

Post: How to recover table structure from InnoDB dictionary

…SYS_COLUMNS` ( `TABLE_ID` bigint(20) unsigned NOT NULL, `POS` int(10) unsigned NOT NULL, `NAME` varchar(255) DEFAULT NULL, `MTYPE` int(10) unsigned DEFAULT NULL, `…where it would make sense it is still zero. If you know how InnoDB uses `PREC` please let me know. mysql> select * from SYS_COLUMNS WHERE

Post: Eventual Consistency in MySQL

…. If the REFERENCED_* columns are non-null, it’s a foreign key. mysql> SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL\G *************************** 1… where the REFERENCED_* columns are non-null.  From that information, we can generate an exclusion-join query for each foreign key relationship: mysql> SELECT CONCAT( ‘SELECT

Post: When is MIN(DATE) != MIN(DATE) ?

… `bar` (some_other_columns) …. ) ENGINE=InnoDB; When he ran this query: SELECT MIN(update_time) FROM foo WHERE update_time IS NOT NULL AND update_time…:00:00 | +———————+ Very bizarre. On one hand, it seems like MySQL is using date windowing for two-digit dates (this would explain…

Post: COUNT(*) vs COUNT(col)

…, but not COUNT(val). Why ? Because val column is not defined as NOT NULL there can be some NULL values in it and so MySQL have…mysql> select count(*) from fact where i explain select count(*) from fact where i select count(val) from fact where i explain select count(val) from fact where i select

Post: Do you always need index on WHERE column ?

column `has_something` (the column has two values 0 and 1). In reality the right answer is notis faster. And finally for case with 20% rows with has_someting=0 mysql> select count(name) from testr force key (has_something) where

Post: Flexviews - part 3 - improving query performance using materialized views

where this is not useful, simply ignore this column. It is used to prevent wide innodb primary keys on the MV. mysql> select

Post: MySQL 5.6.10 Optimizer Limitations: Index Condition Pushdown

WHERE role_id = 1 and note like ‘%Jaime%’; On a table like this: CREATE TABLE `cast_info` ( `id` int(11) NOT NULLcolumn) and can take advantage of the covering index technique, did actually take more time to execute: mysql> SELECT

Post: MySQL Indexing Best Practices: Webinar Questions Followup

SELECT * FROM TBL WHERE hash=crc32(‘string’) AND string=’string’ The other thing you need to consider is string comparison in MySQL isis not what you’re looking for. Q: I have a primary index on an int (ID) and other indexes on columns

Post: Using UNION to implement loose index scan in MySQL

mysql> SELECT name FROM people WHERE age=18 AND zip IN (12345,12346, 12347) -> UNION ALL -> SELECT name FROM people WHEREMySQL is able to execute it much faster, delivering us expected performance. You can also use this approach when first key column is not in where