Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
1eb005b9
Commit
1eb005b9
authored
Jan 04, 2024
by
Monty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize checking if a table is a statistics table
parent
4ddb1fd7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
35 deletions
+63
-35
sql/lock.cc
sql/lock.cc
+2
-1
sql/sql_base.cc
sql/sql_base.cc
+5
-3
sql/sql_statistics.cc
sql/sql_statistics.cc
+1
-1
sql/table.cc
sql/table.cc
+32
-19
sql/table.h
sql/table.h
+6
-1
sql/wsrep_mysqld.cc
sql/wsrep_mysqld.cc
+17
-10
No files found.
sql/lock.cc
View file @
1eb005b9
...
@@ -153,7 +153,8 @@ lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
...
@@ -153,7 +153,8 @@ lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
if
(
t
->
reginfo
.
lock_type
>=
TL_FIRST_WRITE
)
if
(
t
->
reginfo
.
lock_type
>=
TL_FIRST_WRITE
)
{
{
if
(
t
->
s
->
table_category
==
TABLE_CATEGORY_SYSTEM
)
if
(
t
->
s
->
table_category
==
TABLE_CATEGORY_SYSTEM
||
t
->
s
->
table_category
==
TABLE_CATEGORY_STATISTICS
)
system_count
++
;
system_count
++
;
if
(
t
->
db_stat
&
HA_READ_ONLY
)
if
(
t
->
db_stat
&
HA_READ_ONLY
)
...
...
sql/sql_base.cc
View file @
1eb005b9
...
@@ -9601,9 +9601,11 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list)
...
@@ -9601,9 +9601,11 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list)
for
(
TABLE_LIST
*
tables
=
table_list
;
tables
;
tables
=
tables
->
next_global
)
for
(
TABLE_LIST
*
tables
=
table_list
;
tables
;
tables
=
tables
->
next_global
)
{
{
DBUG_ASSERT
(
tables
->
table
->
s
->
table_category
==
TABLE_CATEGORY_SYSTEM
);
TABLE
*
table
=
tables
->
table
;
tables
->
table
->
file
->
row_logging
=
0
;
DBUG_ASSERT
(
table
->
s
->
table_category
==
TABLE_CATEGORY_SYSTEM
||
tables
->
table
->
use_all_columns
();
table
->
s
->
table_category
==
TABLE_CATEGORY_STATISTICS
);
table
->
file
->
row_logging
=
0
;
table
->
use_all_columns
();
}
}
lex
->
restore_backup_query_tables_list
(
&
query_tables_list_backup
);
lex
->
restore_backup_query_tables_list
(
&
query_tables_list_backup
);
...
...
sql/sql_statistics.cc
View file @
1eb005b9
...
@@ -3299,7 +3299,7 @@ read_statistics_for_tables(THD *thd, TABLE_LIST *tables, bool force_reload)
...
@@ -3299,7 +3299,7 @@ read_statistics_for_tables(THD *thd, TABLE_LIST *tables, bool force_reload)
statistics_for_tables_is_needed
=
true
;
statistics_for_tables_is_needed
=
true
;
}
}
}
}
else
if
(
is_stat_table
(
&
tl
->
db
,
&
tl
->
alias
)
)
else
if
(
table_share
->
table_category
==
TABLE_CATEGORY_STATISTICS
)
found_stat_table
=
true
;
found_stat_table
=
true
;
}
}
...
...
sql/table.cc
View file @
1eb005b9
...
@@ -125,7 +125,9 @@ static bool fix_type_pointers(const char ***typelib_value_names,
...
@@ -125,7 +125,9 @@ static bool fix_type_pointers(const char ***typelib_value_names,
static
field_index_t
find_field
(
Field
**
fields
,
uchar
*
record
,
uint
start
,
static
field_index_t
find_field
(
Field
**
fields
,
uchar
*
record
,
uint
start
,
uint
length
);
uint
length
);
inline
bool
is_system_table_name
(
const
char
*
name
,
size_t
length
);
static
inline
bool
is_system_table_name
(
const
char
*
name
,
size_t
length
);
static
inline
bool
is_statistics_table_name
(
const
char
*
name
,
size_t
length
);
/**************************************************************************
/**************************************************************************
Object_creation_ctx implementation.
Object_creation_ctx implementation.
...
@@ -310,13 +312,12 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
...
@@ -310,13 +312,12 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
if
(
is_system_table_name
(
name
->
str
,
name
->
length
))
if
(
is_system_table_name
(
name
->
str
,
name
->
length
))
return
TABLE_CATEGORY_SYSTEM
;
return
TABLE_CATEGORY_SYSTEM
;
if
(
lex_string_eq
(
&
GENERAL_LOG_NAME
,
name
))
if
(
is_statistics_table_name
(
name
->
str
,
name
->
length
))
return
TABLE_CATEGORY_LOG
;
return
TABLE_CATEGORY_STATISTICS
;
if
(
lex_string_eq
(
&
SLOW_LOG_NAME
,
name
))
return
TABLE_CATEGORY_LOG
;
if
(
lex_string_eq
(
&
TRANSACTION_REG_NAME
,
name
))
if
(
lex_string_eq
(
&
GENERAL_LOG_NAME
,
name
)
||
lex_string_eq
(
&
SLOW_LOG_NAME
,
name
)
||
lex_string_eq
(
&
TRANSACTION_REG_NAME
,
name
))
return
TABLE_CATEGORY_LOG
;
return
TABLE_CATEGORY_LOG
;
return
TABLE_CATEGORY_MYSQL
;
return
TABLE_CATEGORY_MYSQL
;
...
@@ -575,7 +576,7 @@ void free_table_share(TABLE_SHARE *share)
...
@@ -575,7 +576,7 @@ void free_table_share(TABLE_SHARE *share)
and should not contain user tables.
and should not contain user tables.
*/
*/
inline
bool
is_system_table_name
(
const
char
*
name
,
size_t
length
)
static
inline
bool
is_system_table_name
(
const
char
*
name
,
size_t
length
)
{
{
CHARSET_INFO
*
ci
=
system_charset_info
;
CHARSET_INFO
*
ci
=
system_charset_info
;
...
@@ -601,17 +602,6 @@ inline bool is_system_table_name(const char *name, size_t length)
...
@@ -601,17 +602,6 @@ inline bool is_system_table_name(const char *name, size_t length)
my_tolower
(
ci
,
name
[
2
])
==
'm'
&&
my_tolower
(
ci
,
name
[
2
])
==
'm'
&&
my_tolower
(
ci
,
name
[
3
])
==
'e'
)
||
my_tolower
(
ci
,
name
[
3
])
==
'e'
)
||
/* one of mysql.*_stat tables, but not mysql.innodb* tables*/
((
my_tolower
(
ci
,
name
[
length
-
5
])
==
's'
&&
my_tolower
(
ci
,
name
[
length
-
4
])
==
't'
&&
my_tolower
(
ci
,
name
[
length
-
3
])
==
'a'
&&
my_tolower
(
ci
,
name
[
length
-
2
])
==
't'
&&
my_tolower
(
ci
,
name
[
length
-
1
])
==
's'
)
&&
!
(
my_tolower
(
ci
,
name
[
0
])
==
'i'
&&
my_tolower
(
ci
,
name
[
1
])
==
'n'
&&
my_tolower
(
ci
,
name
[
2
])
==
'n'
&&
my_tolower
(
ci
,
name
[
3
])
==
'o'
))
||
/* mysql.event table */
/* mysql.event table */
(
my_tolower
(
ci
,
name
[
0
])
==
'e'
&&
(
my_tolower
(
ci
,
name
[
0
])
==
'e'
&&
my_tolower
(
ci
,
name
[
1
])
==
'v'
&&
my_tolower
(
ci
,
name
[
1
])
==
'v'
&&
...
@@ -624,6 +614,29 @@ inline bool is_system_table_name(const char *name, size_t length)
...
@@ -624,6 +614,29 @@ inline bool is_system_table_name(const char *name, size_t length)
}
}
static
inline
bool
is_statistics_table_name
(
const
char
*
name
,
size_t
length
)
{
CHARSET_INFO
*
ci
=
system_charset_info
;
if
(
length
>
6
)
{
/* one of mysql.*_stat tables, but not mysql.innodb* tables*/
if
((
my_tolower
(
ci
,
name
[
length
-
5
])
==
's'
&&
my_tolower
(
ci
,
name
[
length
-
4
])
==
't'
&&
my_tolower
(
ci
,
name
[
length
-
3
])
==
'a'
&&
my_tolower
(
ci
,
name
[
length
-
2
])
==
't'
&&
my_tolower
(
ci
,
name
[
length
-
1
])
==
's'
)
&&
!
(
my_tolower
(
ci
,
name
[
0
])
==
'i'
&&
my_tolower
(
ci
,
name
[
1
])
==
'n'
&&
my_tolower
(
ci
,
name
[
2
])
==
'n'
&&
my_tolower
(
ci
,
name
[
3
])
==
'o'
))
return
1
;
}
return
0
;
}
/*
/*
Read table definition from a binary / text based .frm file
Read table definition from a binary / text based .frm file
...
...
sql/table.h
View file @
1eb005b9
...
@@ -463,6 +463,11 @@ enum enum_table_category
...
@@ -463,6 +463,11 @@ enum enum_table_category
*/
*/
TABLE_CATEGORY_SYSTEM
=
3
,
TABLE_CATEGORY_SYSTEM
=
3
,
/**
Persistent statistics table
*/
TABLE_CATEGORY_STATISTICS
=
4
,
/**
/**
Log tables.
Log tables.
These tables are an interface provided by the system
These tables are an interface provided by the system
...
@@ -483,7 +488,7 @@ enum enum_table_category
...
@@ -483,7 +488,7 @@ enum enum_table_category
The server implementation perform writes.
The server implementation perform writes.
Log tables are cached in the table cache.
Log tables are cached in the table cache.
*/
*/
TABLE_CATEGORY_LOG
=
4
,
TABLE_CATEGORY_LOG
=
5
,
/**
/**
Other tables in the mysql schema, like global_priv and db
Other tables in the mysql schema, like global_priv and db
...
...
sql/wsrep_mysqld.cc
View file @
1eb005b9
...
@@ -1456,15 +1456,21 @@ bool wsrep_check_mode_after_open_table (THD *thd,
...
@@ -1456,15 +1456,21 @@ bool wsrep_check_mode_after_open_table (THD *thd,
(
db_type
==
DB_TYPE_ARIA
&&
wsrep_check_mode
(
WSREP_MODE_REPLICATE_ARIA
)));
(
db_type
==
DB_TYPE_ARIA
&&
wsrep_check_mode
(
WSREP_MODE_REPLICATE_ARIA
)));
TABLE
*
tbl
=
tables
->
table
;
TABLE
*
tbl
=
tables
->
table
;
DBUG_ASSERT
(
tbl
);
if
(
replicate
)
if
(
replicate
)
{
{
/* It is not recommended to replicate MyISAM as it lacks rollback feature
/*
but if user demands then actions are replicated using TOI.
It is not recommended to replicate MyISAM as it lacks rollback
Following code will kick-start the TOI but this has to be done only once
feature but if user demands then actions are replicated using TOI.
per statement.
Following code will kick-start the TOI but this has to be done
Note: kick-start will take-care of creating isolation key for all tables
only once per statement.
involved in the list (provided all of them are MYISAM or Aria tables). */
if
(
!
is_stat_table
(
&
tables
->
db
,
&
tables
->
alias
))
Note: kick-start will take-care of creating isolation key for
all tables involved in the list (provided all of them are MYISAM
or Aria tables).
*/
if
((
tbl
&&
tbl
->
s
->
table_category
!=
TABLE_CATEGORY_STATISTICS
)
||
(
!
tbl
&&
!
is_stat_table
(
&
tables
->
db
,
&
tables
->
alias
)))
{
{
if
(
tbl
->
s
->
primary_key
==
MAX_KEY
&&
if
(
tbl
->
s
->
primary_key
==
MAX_KEY
&&
wsrep_check_mode
(
WSREP_MODE_REQUIRED_PRIMARY_KEY
))
wsrep_check_mode
(
WSREP_MODE_REQUIRED_PRIMARY_KEY
))
...
@@ -1482,13 +1488,14 @@ bool wsrep_check_mode_after_open_table (THD *thd,
...
@@ -1482,13 +1488,14 @@ bool wsrep_check_mode_after_open_table (THD *thd,
db_type
!=
DB_TYPE_PERFORMANCE_SCHEMA
)
db_type
!=
DB_TYPE_PERFORMANCE_SCHEMA
)
{
{
bool
is_system_db
=
(
tbl
&&
bool
is_system_db
=
(
tbl
&&
((
strcmp
(
tbl
->
s
->
db
.
str
,
"mysql"
)
==
0
)
||
(
!
strcmp
(
tbl
->
s
->
db
.
str
,
"mysql"
)
||
(
strcmp
(
tbl
->
s
->
db
.
str
,
"information_schema"
)
==
0
)));
(
tbl
->
s
->
table_category
==
TABLE_CATEGORY_INFORMATION
&&
!
strcmp
(
tbl
->
s
->
db
.
str
,
"information_schema"
))));
if
(
!
is_system_db
&&
if
(
!
is_system_db
&&
!
is_temporary_table
(
tables
))
!
is_temporary_table
(
tables
))
{
{
if
(
db_type
!=
DB_TYPE_INNODB
&&
if
(
db_type
!=
DB_TYPE_INNODB
&&
wsrep_check_mode
(
WSREP_MODE_STRICT_REPLICATION
))
wsrep_check_mode
(
WSREP_MODE_STRICT_REPLICATION
))
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment