mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
BUG#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE
Details: - Merge : 5.1 -> 5.5 - Addded a new test case which was not added in 5.1 because PS was not there in 5.1.
This commit is contained in:
commit
a7d47adf23
3 changed files with 138 additions and 31 deletions
53
mysql-test/r/bug12427262.result
Normal file
53
mysql-test/r/bug12427262.result
Normal file
|
@ -0,0 +1,53 @@
|
|||
#
|
||||
# Bug#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE.
|
||||
#
|
||||
create database show_table_db;
|
||||
use show_table_db;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
create table t4 (c1 int);
|
||||
create table t5 (c1 int);
|
||||
create table t6 (c1 int);
|
||||
create table t7 (c1 int);
|
||||
create table t8 (c1 int);
|
||||
create table t9 (c1 int);
|
||||
create table t10 (c1 int);
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_before;
|
||||
show tables;
|
||||
Tables_in_show_table_db
|
||||
t1
|
||||
t10
|
||||
t2
|
||||
t3
|
||||
t4
|
||||
t5
|
||||
t6
|
||||
t7
|
||||
t8
|
||||
t9
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after;
|
||||
select @count_read_after-@count_read_before;
|
||||
@count_read_after-@count_read_before
|
||||
0.000000000000000000000000000000
|
||||
show full tables;
|
||||
Tables_in_show_table_db Table_type
|
||||
t1 BASE TABLE
|
||||
t10 BASE TABLE
|
||||
t2 BASE TABLE
|
||||
t3 BASE TABLE
|
||||
t4 BASE TABLE
|
||||
t5 BASE TABLE
|
||||
t6 BASE TABLE
|
||||
t7 BASE TABLE
|
||||
t8 BASE TABLE
|
||||
t9 BASE TABLE
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after;
|
||||
select @count_read_after-@count_read_before;
|
||||
@count_read_after-@count_read_before
|
||||
10.000000000000000000000000000000
|
||||
drop table t1;
|
||||
drop database show_table_db;
|
48
mysql-test/t/bug12427262.test
Normal file
48
mysql-test/t/bug12427262.test
Normal file
|
@ -0,0 +1,48 @@
|
|||
--echo #
|
||||
--echo # Bug#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE.
|
||||
--echo #
|
||||
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_perfschema.inc
|
||||
|
||||
--disable_warnings
|
||||
create database show_table_db;
|
||||
use show_table_db;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
create table t4 (c1 int);
|
||||
create table t5 (c1 int);
|
||||
create table t6 (c1 int);
|
||||
create table t7 (c1 int);
|
||||
create table t8 (c1 int);
|
||||
create table t9 (c1 int);
|
||||
create table t10 (c1 int);
|
||||
--enable_warnings
|
||||
|
||||
# Query PS to know initial read count for frm file.
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_before;
|
||||
|
||||
show tables;
|
||||
|
||||
# Query PS to know read count for frm file after above query. It should
|
||||
# not be changed as FRM file will not be opened for above query.
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after;
|
||||
|
||||
select @count_read_after-@count_read_before;
|
||||
|
||||
show full tables;
|
||||
|
||||
# Query PS to know read count for frm file after above query. COUNT_READ
|
||||
# will be incremented by 1 as FRM file will be opened for above query.
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_db/%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after;
|
||||
|
||||
select @count_read_after-@count_read_before;
|
||||
|
||||
--disable_warnings
|
||||
drop table t1;
|
||||
drop database show_table_db;
|
||||
--enable_warnings
|
|
@ -3192,39 +3192,44 @@ end:
|
|||
|
||||
static int fill_schema_table_names(THD *thd, TABLE *table,
|
||||
LEX_STRING *db_name, LEX_STRING *table_name,
|
||||
bool with_i_schema)
|
||||
bool with_i_schema,
|
||||
bool need_table_type)
|
||||
{
|
||||
if (with_i_schema)
|
||||
/* Avoid opening FRM files if table type is not needed. */
|
||||
if (need_table_type)
|
||||
{
|
||||
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
|
||||
system_charset_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
enum legacy_db_type not_used;
|
||||
char path[FN_REFLEN + 1];
|
||||
(void) build_table_filename(path, sizeof(path) - 1, db_name->str,
|
||||
table_name->str, reg_ext, 0);
|
||||
switch (dd_frm_type(thd, path, ¬_used)) {
|
||||
case FRMTYPE_ERROR:
|
||||
table->field[3]->store(STRING_WITH_LEN("ERROR"),
|
||||
system_charset_info);
|
||||
break;
|
||||
case FRMTYPE_TABLE:
|
||||
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
|
||||
system_charset_info);
|
||||
break;
|
||||
case FRMTYPE_VIEW:
|
||||
table->field[3]->store(STRING_WITH_LEN("VIEW"),
|
||||
system_charset_info);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
if (thd->is_error() && thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
|
||||
if (with_i_schema)
|
||||
{
|
||||
thd->clear_error();
|
||||
return 0;
|
||||
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
|
||||
system_charset_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
enum legacy_db_type not_used;
|
||||
char path[FN_REFLEN + 1];
|
||||
(void) build_table_filename(path, sizeof(path) - 1, db_name->str,
|
||||
table_name->str, reg_ext, 0);
|
||||
switch (dd_frm_type(thd, path, ¬_used)) {
|
||||
case FRMTYPE_ERROR:
|
||||
table->field[3]->store(STRING_WITH_LEN("ERROR"),
|
||||
system_charset_info);
|
||||
break;
|
||||
case FRMTYPE_TABLE:
|
||||
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
|
||||
system_charset_info);
|
||||
break;
|
||||
case FRMTYPE_VIEW:
|
||||
table->field[3]->store(STRING_WITH_LEN("VIEW"),
|
||||
system_charset_info);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
if (thd->is_error() && thd->stmt_da->sql_errno() == ER_NO_SUCH_TABLE)
|
||||
{
|
||||
thd->clear_error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (schema_table_store_record(thd, table))
|
||||
|
@ -3763,7 +3768,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
if (schema_table_idx == SCH_TABLE_NAMES)
|
||||
{
|
||||
if (fill_schema_table_names(thd, tables->table, db_name,
|
||||
table_name, with_i_schema))
|
||||
table_name, with_i_schema,
|
||||
lex->verbose))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue