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
f312ef9b
Commit
f312ef9b
authored
Sep 20, 2024
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further suggestions on optimizing opening tables
parent
5a3d78d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
sql/mdl.h
sql/mdl.h
+2
-1
sql/sql_base.cc
sql/sql_base.cc
+11
-6
No files found.
sql/mdl.h
View file @
f312ef9b
...
...
@@ -704,6 +704,7 @@ class MDL_ticket : public MDL_wait_for_subgraph, public ilist_node<>
*/
MDL_ticket
*
next_in_context
;
MDL_ticket
**
prev_in_context
;
TABLE
*
object
;
public:
#ifdef WITH_WSREP
void
wsrep_report
(
bool
debug
)
const
;
...
...
@@ -1093,7 +1094,7 @@ class MDL_context
bool
try_acquire_lock_impl
(
MDL_request
*
mdl_request
,
MDL_ticket
**
out_ticket
);
bool
fix_pins
();
public:
/**
Ticket hash. Stores only locked tickets.
*/
...
...
sql/sql_base.cc
View file @
f312ef9b
...
...
@@ -1954,11 +1954,15 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
!
(
flags
&
MYSQL_OPEN_GET_NEW_TABLE
))
{
// Using table locks
TABLE
*
best_table
=
0
;
int
best_distance
=
INT_MIN
;
for
(
table
=
thd
->
open_tables
;
table
;
table
=
table
->
next
)
thd
->
mdl_context
.
ticket_hash
.
find
(
table_list
->
mdl_request
.
key
,
[
thd
,
&
best_table
,
alias
,
key
,
key_length
,
table_list
]
(
const
MDL_ticket
*
t
)
{
if
(
table
->
s
->
table_cache_key
.
length
==
key_length
&&
!
memcmp
(
table
->
s
->
table_cache_key
.
str
,
key
,
key_length
))
TABLE
*
table
=
t
->
object
;
int
best_distance
=
INT_MIN
;
if
(
!
memcmp
(
t
->
get_key
()
->
ptr
(),
key
,
key_length
))
{
if
(
!
my_strcasecmp
(
system_charset_info
,
table
->
alias
.
c_ptr
(),
alias
)
&&
table
->
query_id
!=
thd
->
query_id
&&
/* skip tables already used */
...
...
@@ -1993,12 +1997,13 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
between calling statement and SP/trigger is done in
lock_tables().
*/
break
;
}
return
true
;
}
}
}
}
return
false
;
});
if
(
best_table
)
{
table
=
best_table
;
...
...
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