Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
N/A
-
None
Description
atomic.alter_table became more than 2x slow in after MDEV-20912, commit 7fcaab7aaac.
The reason is the server startup, that became much slower, in particular, the function init_compiled_charsets(). That line
649
|
my_bool add_alias_for_collation(LEX_CSTRING *collation_name, LEX_CSTRING *alias,
|
650
|
uint alias_id)
|
651
|
{
|
652
|
char *coll_name, *comment; |
653
|
struct charset_info_st *new_ci; |
654
|
CHARSET_INFO *org;
|
655
|
MY_CHARSET_LOADER loader;
|
656
|
char comment_buff[64+15]; |
657
|
size_t comment_length; |
658
|
uint org_id= get_collation_number_internal(collation_name->str);
|
659
|
DBUG_ASSERT(org_id);
|
660
|
DBUG_ASSERT(all_charsets[org_id]);
|
is called for every 0900 collation and it iterates the list of collations, so it's O(N²). If I comment this single function call away, the execution time of atomic.alter_table goes back to normal.
Note that this function is a complete waste of time, because collation ids are fixed and can never change, there is no need to look them up at runtime.
Fixed by adding the MariaDB internal collation number in the "0900" alias
lookup array. This is fine as collation numbers never changes.
Pushed to 11.4 branch