Loading mysql-test/r/information_schema.result +9 −0 Original line number Diff line number Diff line Loading @@ -1646,4 +1646,13 @@ drop table t1; drop function f1; select * from information_schema.tables where 1=sleep(100000); select * from information_schema.columns where 1=sleep(100000); explain select count(*) from information_schema.tables; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases explain select count(*) from information_schema.columns; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE columns ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases explain select count(*) from information_schema.views; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE views ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases End of 5.1 tests. mysql-test/t/information_schema.test +8 −0 Original line number Diff line number Diff line Loading @@ -1338,4 +1338,12 @@ where state='User sleep' and info='select * from information_schema.columns where 1=sleep(100000)'; --source include/wait_condition.inc # # Bug#38918 selecting from information_schema.columns is disproportionately slow # explain select count(*) from information_schema.tables; explain select count(*) from information_schema.columns; explain select count(*) from information_schema.views; --echo End of 5.1 tests. sql/sql_show.cc +11 −1 Original line number Diff line number Diff line Loading @@ -2962,7 +2962,7 @@ static int fill_schema_table_names(THD *thd, TABLE *table, @retval SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE */ static uint get_table_open_method(TABLE_LIST *tables, uint get_table_open_method(TABLE_LIST *tables, ST_SCHEMA_TABLE *schema_table, enum enum_schema_tables schema_table_idx) { Loading @@ -2973,12 +2973,22 @@ static uint get_table_open_method(TABLE_LIST *tables, { Field **ptr, *field; int table_open_method= 0, field_indx= 0; uint star_table_open_method= OPEN_FULL_TABLE; bool used_star= true; // true if '*' is used in select for (ptr=tables->table->field; (field= *ptr) ; ptr++) { star_table_open_method= min(star_table_open_method, schema_table->fields_info[field_indx].open_method); if (bitmap_is_set(tables->table->read_set, field->field_index)) { used_star= false; table_open_method|= schema_table->fields_info[field_indx].open_method; } field_indx++; } if (used_star) return star_table_open_method; return table_open_method; } /* I_S tables which use get_all_tables but can not be optimized */ Loading Loading
mysql-test/r/information_schema.result +9 −0 Original line number Diff line number Diff line Loading @@ -1646,4 +1646,13 @@ drop table t1; drop function f1; select * from information_schema.tables where 1=sleep(100000); select * from information_schema.columns where 1=sleep(100000); explain select count(*) from information_schema.tables; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases explain select count(*) from information_schema.columns; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE columns ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases explain select count(*) from information_schema.views; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE views ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases End of 5.1 tests.
mysql-test/t/information_schema.test +8 −0 Original line number Diff line number Diff line Loading @@ -1338,4 +1338,12 @@ where state='User sleep' and info='select * from information_schema.columns where 1=sleep(100000)'; --source include/wait_condition.inc # # Bug#38918 selecting from information_schema.columns is disproportionately slow # explain select count(*) from information_schema.tables; explain select count(*) from information_schema.columns; explain select count(*) from information_schema.views; --echo End of 5.1 tests.
sql/sql_show.cc +11 −1 Original line number Diff line number Diff line Loading @@ -2962,7 +2962,7 @@ static int fill_schema_table_names(THD *thd, TABLE *table, @retval SKIP_OPEN_TABLE | OPEN_FRM_ONLY | OPEN_FULL_TABLE */ static uint get_table_open_method(TABLE_LIST *tables, uint get_table_open_method(TABLE_LIST *tables, ST_SCHEMA_TABLE *schema_table, enum enum_schema_tables schema_table_idx) { Loading @@ -2973,12 +2973,22 @@ static uint get_table_open_method(TABLE_LIST *tables, { Field **ptr, *field; int table_open_method= 0, field_indx= 0; uint star_table_open_method= OPEN_FULL_TABLE; bool used_star= true; // true if '*' is used in select for (ptr=tables->table->field; (field= *ptr) ; ptr++) { star_table_open_method= min(star_table_open_method, schema_table->fields_info[field_indx].open_method); if (bitmap_is_set(tables->table->read_set, field->field_index)) { used_star= false; table_open_method|= schema_table->fields_info[field_indx].open_method; } field_indx++; } if (used_star) return star_table_open_method; return table_open_method; } /* I_S tables which use get_all_tables but can not be optimized */ Loading