May 24, 2012

Post: Enum Fields VS Varchar VS Int + Joined table: What is Faster?

…), KEY state (state) ) ENGINE=MyISAM; 3) Table with INT: CREATE TABLE cities_join ( id int(10) unsigned NOT NULL auto_increment, state_id…): 0.085637 3) Results for INT + join: select SQL_NO_CACHE c.city from cities_join c JOIN states s ON (s.id = c…: mysql> explain select SQL_NO_CACHE c.city from cities_join c JOIN states s ON (s.id = c.state_id) ORDER…

Post: Joining on range? Wrong!

…three very simple tables: CREATE TABLE `products` ( `prd_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `prd_name` …3 bytes). Also ref shows two columns used in join. SHOW STATUS LIKE ‘Handler_read%’; +———————–+——-+ | Variable_name | Value | +———————–+——-+ | …

Post: Using CHAR keys for joins, how much is the overhead ?

… and join query performed on INT fields: CREATE TABLE `intjoin` ( `i` int(10) unsigned NOT NULL, `c` char(10) DEFAULT NULL, `j` int(10… seconds on Innodb which is about 50% slower compared to Joining on Int, for MyISAM however the time became 11.0 seconds which is over 6 times slower than joining on the integer. In…

Post: How adding another table to JOIN can improve performance ?

… most typical the fewer tables (for the same database) you join the better performance you will get. As for any rules…_increment, `d` date NOT NULL, `group_id` int(10) unsigned NOT NULL, `events` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY… matching range from some pre-generated table and use the join to retrieve the rows from original table: mysql> show create…

Post: Using delayed JOIN to optimize count(*) and LIMIT queries

… for such result sets MySQL will perform the join even if you use LEFT JOIN so it is not needed which slows… better performance you can “Help” MySQL and remove JOIN for count(*) and do JOIN after limiting result set for retrieval queries. Lets… NOT NULL, KEY `i` (`i`,`val`) ) CREATE TABLE `dim` ( `id` int(10) unsigned NOT NULL auto_increment, `pad` varchar(100) NOT…

Post: Join performance of MyISAM and Innodb

join clause to be id, i and C columns appropriately. CREATE TABLE `t1` ( `id` int(10) unsigned NOT NULL default ’0′, `i` int…. I guess the reasons are the following: Innodb primary key joins are very fast as data is clustered together with index… MyISAM still a bit better by primary key join than for secondary key join. I guess because it knows for sure there…

Post: How is join_buffer_size allocated?

… allocated to cache rows from each table in a join when the join can’t use an index. This is because we… very big 14180 records 14181 ******************************************************************************/ 14182 14183 static int 14184 join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) 14185 { … snip…

Post: JOIN Performance & Charsets

… a specific reason. Either way, the character sets used on joined columns can have a significant impact on the performance of…_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `t2` ( `id` int unsigned NOT NULL auto_increment, `char_id` char(6) NOT… SELECT SQL_NO_CACHE COUNT(t1.char_id) > FROM t1 > JOIN t2 USING (char_id)\G *************************** 1. row *************************** id: 1 select…

Post: Be careful when joining on CONCAT

… simple join. It was a join on tb1.vid = CONCAT(‘prefix-’, tb2.id) with tb1.vid – indexed varchar(100) and tb2.id – int(11) column. No matter what I did – forced it to use key, forced a different join order, it did… that really helps: mysql> EXPLAIN -> SELECT -> tb1.* -> FROM tb2 -> STRAIGHT_JOIN tb1 -> WHERE -> ( -> tb1.vid LIKE ‘prefix-%’ AND -> tb1.vid = CONCAT…

Post: Analyzing air traffic performance with InfoBright and MonetDB

int(11) DEFAULT NULL, `DepTime` int(11) DEFAULT NULL, `DepDelay` int(11) DEFAULT NULL, `DepDelayMinutes` int(11) DEFAULT NULL, `DepDel15` int(11) DEFAULT NULL, `DepartureDelayGroups` int…WHERE DepDelay>10 AND Year=2007 GROUP BY carrier) t JOIN (SELECT carrier, count(*) AS c2 FROM ontime WHERE Year=…