Skip to content
Permalink
Browse files
(Part#2) MDEV-13049 Querying INFORMATION_SCHEMA becomes slow in Maria…
…DB 10.1

This is a 10.3 specific part of MDEV-13049.
It disables automatic sorting for
"SELECT .. FROM INFORMATION_SCHEMA.{SCHEMATA|TABLES}"
and adjusts the affected tests accordingly.
  • Loading branch information
abarkov committed Oct 31, 2017
1 parent 835cbbc commit 5d3ed9a
Show file tree
Hide file tree
Showing 64 changed files with 366 additions and 212 deletions.
@@ -39,12 +39,14 @@ BEGIN

-- Dump all databases, there should be none
-- except those that was created during bootstrap
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY BINARY SCHEMA_NAME;

-- and the mtr_wsrep_notify schema which is populated by the std_data/wsrep_notify.sh script
-- and the suite/galera/t/galera_var_notify_cmd.test
-- and the wsrep_schema schema that may be created by Galera
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema');
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema')
ORDER BY BINARY SCHEMA_NAME;

-- The test database should not contain any tables
SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES
@@ -112,7 +112,8 @@ select @a|
/**/ while (select count(*) from information_schema.tables where table_schema='test')
do
select concat('drop table ', table_name) into @a
from information_schema.tables where table_schema='test' limit 1;
from information_schema.tables where table_schema='test'
order by table_name limit 1;
select @a as 'executing:';
prepare dt from @a;
execute dt;
@@ -586,8 +586,8 @@ select s1 from t1 where s1 in (select version from
information_schema.tables) union select version from
information_schema.tables;
s1
11
10
11
drop table t1;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table
@@ -770,11 +770,18 @@ table_name
v2
v3
select column_name from information_schema.columns
where table_schema='test';
where table_schema='test' and table_name='t4';
column_name
f1
select column_name from information_schema.columns
where table_schema='test' and table_name='v2';
column_name
Warnings:
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
select column_name from information_schema.columns
where table_schema='test' and table_name='v3';
column_name
Warnings:
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
select index_name from information_schema.statistics where table_schema='test';
index_name
@@ -839,7 +846,8 @@ drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
information_schema.columns
where data_type = 'longtext' and table_schema != 'performance_schema';
where data_type = 'longtext' and table_schema != 'performance_schema'
order by binary table_name, ordinal_position;
table_schema table_name column_name
information_schema ALL_PLUGINS PLUGIN_DESCRIPTION
information_schema COLUMNS COLUMN_DEFAULT
@@ -860,7 +868,8 @@ information_schema TRIGGERS ACTION_CONDITION
information_schema TRIGGERS ACTION_STATEMENT
information_schema VIEWS VIEW_DEFINITION
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime' and table_name not like 'innodb_%';
where data_type = 'datetime' and table_name not like 'innodb_%'
order by binary table_name, ordinal_position;
table_name column_name data_type
EVENTS EXECUTE_AT datetime
EVENTS STARTS datetime
@@ -1275,7 +1284,7 @@ sql security definer view v2 as select 1;
connect con16681,localhost,mysqltest_1,,test;
connection con16681;
select * from information_schema.views
where table_name='v1' or table_name='v2';
where table_name='v1' or table_name='v2' order by table_name;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM
def test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED
def test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED
@@ -1288,7 +1297,7 @@ set @a:= '.';
create table t1(f1 char(5));
create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test';
from information_schema.tables where table_schema = 'test' order by table_name;
concat(@a, table_name) @a table_name
.t1 . t1
.t2 . t2
@@ -1375,7 +1384,8 @@ create table t2 (f1 int(11), f2 int(11));
select table_name from information_schema.tables
where table_schema = 'test' and table_name not in
(select table_name from information_schema.columns
where table_schema = 'test' and column_name = 'f3');
where table_schema = 'test' and column_name = 'f3')
order by table_name;
table_name
t1
t2
@@ -1384,7 +1394,7 @@ create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
create table t2 (f1 int, f2 int);
create view v2 as select f1+1 as a, f2 as b from t2;
select table_name, is_updatable from information_schema.views;
select table_name, is_updatable from information_schema.views order by table_name;
table_name is_updatable
v1 NO
v2 YES
@@ -1843,12 +1853,12 @@ rename table t2 to t3;
connection default;
# These statements should not be blocked by pending lock requests
select table_name, column_name, data_type from information_schema.columns
where table_schema = 'test' and table_name in ('t1', 't2');
where table_schema = 'test' and table_name in ('t1', 't2') order by table_name, column_name;
table_name column_name data_type
t1 i int
t2 j int
select table_name, auto_increment from information_schema.tables
where table_schema = 'test' and table_name in ('t1', 't2');
where table_schema = 'test' and table_name in ('t1', 't2') order by table_name;
table_name auto_increment
t1 NULL
t2 1
@@ -1997,7 +2007,7 @@ connect con12828477_2, localhost, root,,mysqltest;
# Wait while the above RENAME is blocked.
# Issue query to I_S which will open 't0' and get
# blocked on 't1' because of RENAME.
select table_name, auto_increment from information_schema.tables where table_schema='mysqltest';
select table_name, auto_increment from information_schema.tables where table_schema='mysqltest' and table_name='t0' union select table_name, auto_increment from information_schema.tables where table_schema='mysqltest' and table_name<>'t0' order by table_name;
connect con12828477_3, localhost, root,,mysqltest;
# Wait while the above SELECT is blocked.
#
@@ -11,7 +11,7 @@ create table t2 (x int);
create table t3 (x int);
create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ;
delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
select * from t4;
select * from t4 order by table_name;
table_name
t1
t2
@@ -72,14 +72,14 @@ create function f2 () returns int return (select max(i) from t2);
create view v2 as select f2();
drop table t2;
select table_name, table_type, table_comment from information_schema.tables
where table_schema='test';
where table_schema='test' order by table_name;
table_name table_type table_comment
t1 BASE TABLE
v1 VIEW VIEW
v2 VIEW VIEW
drop table t1;
select table_name, table_type, table_comment from information_schema.tables
where table_schema='test';
where table_schema='test' order by table_name;
table_name table_type table_comment
v1 VIEW VIEW
v2 VIEW VIEW
@@ -10,18 +10,18 @@ TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
def test PRIMARY test t1 PRIMARY KEY
def test PRIMARY test t2 PRIMARY KEY
def test PRIMARY test t3 PRIMARY KEY
def test t2_ibfk_1 test t2 FOREIGN KEY
def test t2_ibfk_2 test t2 FOREIGN KEY
def test PRIMARY test t3 PRIMARY KEY
def test t3_ibfk_1 test t3 FOREIGN KEY
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
def test PRIMARY def test t1 id 1 NULL NULL NULL NULL
def test PRIMARY def test t2 id 1 NULL NULL NULL NULL
def test PRIMARY def test t3 id 1 NULL NULL NULL NULL
def test t2_ibfk_1 def test t2 t1_id 1 1 test t1 id
def test t2_ibfk_2 def test t2 t1_id 1 1 test t1 id
def test PRIMARY def test t3 id 1 NULL NULL NULL NULL
def test t3_ibfk_1 def test t3 id 1 1 test t2 t1_id
def test t3_ibfk_1 def test t3 t2_id 2 2 test t2 id
drop table t3, t2, t1;
@@ -72,11 +72,12 @@ constraint fk_t1_1 foreign key (idtype) references `t-2` (id)
use test;
select referenced_table_schema, referenced_table_name
from information_schema.key_column_usage
where constraint_schema = 'db-1';
where constraint_schema = 'db-1'
order by referenced_table_schema, referenced_table_name;
referenced_table_schema referenced_table_name
NULL NULL
db-1 t-2
NULL NULL
db-1 t-2
drop database `db-1`;
create table t1(id int primary key) engine = Innodb;
create table t2(pid int, foreign key (pid) references t1(id)) engine = Innodb;
@@ -61,7 +61,7 @@ partition x2 values less than (5)
( subpartition x21 tablespace t1,
subpartition x22 tablespace t2)
);
select * from information_schema.partitions where table_schema="test";
select * from information_schema.partitions where table_schema="test" order by table_name, partition_name;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
def test t1 x1 x11 1 1 RANGE HASH `a` `a` + `b` 1 0 0 0 # 1024 0 # # NULL NULL default t1
def test t1 x1 x12 1 2 RANGE HASH `a` `a` + `b` 1 0 0 0 # 1024 0 # # NULL NULL default t2
@@ -2,7 +2,7 @@ install soname 'ha_blackhole';
install soname 'ha_archive';
create table t1 (a int) engine=blackhole;
create table t2 (a int) engine=archive;
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
table_catalog def
table_schema test
table_name t1
@@ -12,6 +12,7 @@ row_format Fixed
table_rows 0
data_length 0
table_comment
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
table_catalog def
table_schema test
table_name t2
@@ -24,7 +25,7 @@ table_comment
flush tables;
uninstall plugin blackhole;
uninstall plugin archive;
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
table_catalog def
table_schema test
table_name t1
@@ -34,6 +35,11 @@ row_format NULL
table_rows NULL
data_length NULL
table_comment Unknown storage engine 'BLACKHOLE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
table_catalog def
table_schema test
table_name t2
@@ -46,9 +52,6 @@ table_comment Unknown storage engine 'ARCHIVE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
Level Warning
Code 1286
Message Unknown storage engine 'ARCHIVE'
Phase 1/7: Checking and upgrading mysql database
Processing databases
@@ -109,7 +112,7 @@ Error : Unknown storage engine 'ARCHIVE'
error : Corrupt
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
table_catalog def
table_schema test
table_name t1
@@ -119,6 +122,11 @@ row_format NULL
table_rows NULL
data_length NULL
table_comment Unknown storage engine 'BLACKHOLE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
table_catalog def
table_schema test
table_name t2
@@ -131,9 +139,6 @@ table_comment Unknown storage engine 'ARCHIVE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
Level Warning
Code 1286
Message Unknown storage engine 'ARCHIVE'
alter table mysql.user drop column default_role, drop column max_statement_time;
Phase 1/7: Checking and upgrading mysql database
@@ -195,7 +200,7 @@ Error : Unknown storage engine 'ARCHIVE'
error : Corrupt
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
table_catalog def
table_schema test
table_name t1
@@ -205,6 +210,11 @@ row_format NULL
table_rows NULL
data_length NULL
table_comment Unknown storage engine 'BLACKHOLE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
table_catalog def
table_schema test
table_name t2
@@ -217,9 +227,6 @@ table_comment Unknown storage engine 'ARCHIVE'
Warnings:
Level Warning
Code 1286
Message Unknown storage engine 'BLACKHOLE'
Level Warning
Code 1286
Message Unknown storage engine 'ARCHIVE'
alter table mysql.user drop column default_role, drop column max_statement_time;
Phase 1/7: Checking and upgrading mysql database
@@ -256,8 +263,8 @@ mysql.user OK
Upgrading from a version before MariaDB-10.1
Phase 2/7: Installing used storage engines
Checking for tables with unknown storage engine
installing plugin for 'blackhole' storage engine
installing plugin for 'archive' storage engine
installing plugin for 'blackhole' storage engine
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
@@ -273,7 +280,7 @@ test.t1 OK
test.t2 OK
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
table_catalog def
table_schema test
table_name t1
@@ -283,6 +290,7 @@ row_format Fixed
table_rows 0
data_length 0
table_comment
select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
table_catalog def
table_schema test
table_name t2

0 comments on commit 5d3ed9a

Please sign in to comment.