Show
added a comment - On the question why Maria_Toku_Optimizer_Off is so much slower than Maria_Myisam_Optimizer_off. Comparing the query plans:
diff -u Maria_MyIsam_Optimizer_Off/Extended\ Plan.csv Maria_Toku_Optimizer_Off/Extended\ Plan.csv
--- Maria_MyIsam_Optimizer_Off/Extended Plan.csv 2014-05-22 20:51:52.000000000 +0400
+++ Maria_Toku_Optimizer_Off/Extended Plan.csv 2014-05-22 20:59:34.000000000 +0400
@@ -1,5 +1,5 @@
id,select_type,table,type,possible_keys,key,key_len,ref,rows,filtered,Extra
-1,PRIMARY,wh_fbk_data_ctxt_d,ref,"PRIMARY,WH_FBK_DATA_CTXT_D_N1,WH_FBK_DATA_CTXT_D_N2,WH_FBK_DATA_CTXT_D_M1,WH_FBK_DATA_CTXT_D_M2",PRIMARY,8,const,14,100.00,"Using where; Using temporary; Using filesort"
+1,PRIMARY,wh_fbk_data_ctxt_d,ref,"PRIMARY,WH_FBK_DATA_CTXT_D_N1,WH_FBK_DATA_CTXT_D_N2,WH_FBK_DATA_CTXT_D_M1,WH_FBK_DATA_CTXT_D_M2",PRIMARY,8,const,15,100.00,"Using where; Using temporary; Using filesort"
1,PRIMARY,wh_tag_group_d,ref,WH_TAG_GROUP_D_M1,WH_TAG_GROUP_D_M1,8,const,4,100.00,"Using where"
-1,PRIMARY,wh_tag_d,ref,"PRIMARY,WH_TAG_D_M2,WH_TAG_D_M1",WH_TAG_D_M1,8,const,50,100.00,"Using where; Distinct"
+1,PRIMARY,wh_tag_d,ref,"PRIMARY,WH_TAG_D_M2,WH_TAG_D_M1",PRIMARY,8,const,75,100.00,"Using where; Distinct"
-2,MATERIALIZED,wh_tagged_attr_fbk_data_f,ALL,"PRIMARY,WH_TAGGED_ATTR_FBK_DATA_F_M1,WH_TAGGED_ATTR_FBK_DATA_F_F3,WH_TAGGED_ATTR_FBK_DATA_F_F1,WH_TAGGED_ATTR_FBK_DATA_F_F2,WH_TAGGED_ATTR_FBK_DATA_F_F4",NULL,NULL,NULL,842779,100.00,"Using where"
+2,MATERIALIZED,wh_tagged_attr_fbk_data_f,ref,"PRIMARY,WH_TAGGED_ATTR_FBK_DATA_F_M1,WH_TAGGED_ATTR_FBK_DATA_F_F3,WH_TAGGED_ATTR_FBK_DATA_F_F1,WH_TAGGED_ATTR_FBK_DATA_F_F2,WH_TAGGED_ATTR_FBK_DATA_F_F4",WH_TAGGED_ATTR_FBK_DATA_F_F3,8,const,8427,100.00,"Using where"
The join orders are the same.
wh_fbk_data_ctxt_d has small difference in #rows.
Access to wh_tag_d uses different indexes (WH_TAG_D_M1 vs PRIMARY) and different #rows (50 vs 75). This shouldn't cause 10x difference...
wh_tagged_attr_fbk_data_f is vastly different. MyISAM uses full table scan, expecting 842,779 rows. With TokuDB, the query plan is to use ref(const) on index WH_TAGGED_ATTR_FBK_DATA_F_F3, and it expects to read 8427 rows.
I suspect TokuDB returns a very optimistic records_in_range estimate for wh_tagged_attr_fbk_data_f. If one really could read just 8427 rows from that table, we would have picked ref access with MyISAM.
Sivaram Dandibhotla , can you try the query with "FROM wh_tag_d" replaced with "FROM wh_tag_d USE INDEX()". TokuDB, optimizer_switch='semijoin=off' ?
On the question why Maria_Toku_Optimizer_Off is so much slower than Maria_Myisam_Optimizer_off. Comparing the query plans:
The join orders are the same.
I suspect TokuDB returns a very optimistic records_in_range estimate for wh_tagged_attr_fbk_data_f. If one really could read just 8427 rows from that table, we would have picked ref access with MyISAM.
Sivaram Dandibhotla, can you try the query with "FROM wh_tag_d" replaced with "FROM wh_tag_d USE INDEX()". TokuDB, optimizer_switch='semijoin=off' ?