mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-21 22:41:29 +00:00
[Bots] Fix Slow Query in QueryNameAvailablity (#2781)
This commit is contained in:
parent
7e35d5aa79
commit
293f79268d
@ -35,7 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define CURRENT_BINARY_DATABASE_VERSION 9217
|
#define CURRENT_BINARY_DATABASE_VERSION 9217
|
||||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9036
|
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9037
|
||||||
|
|
||||||
#define COMPILE_DATE __DATE__
|
#define COMPILE_DATE __DATE__
|
||||||
#define COMPILE_TIME __TIME__
|
#define COMPILE_TIME __TIME__
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
9034|2022_12_02_bot_spell_settings.sql|SHOW COLUMNS FROM `bot_data` LIKE 'enforce_spell_settings'|empty|
|
9034|2022_12_02_bot_spell_settings.sql|SHOW COLUMNS FROM `bot_data` LIKE 'enforce_spell_settings'|empty|
|
||||||
9035|2022_12_04_bot_archery.sql|SHOW COLUMNS FROM `bot_data` LIKE 'archery_setting'|empty|
|
9035|2022_12_04_bot_archery.sql|SHOW COLUMNS FROM `bot_data` LIKE 'archery_setting'|empty|
|
||||||
9036|2023_01_19_drop_bot_views.sql|SHOW TABLES LIKE 'vw_groups'|not_empty|
|
9036|2023_01_19_drop_bot_views.sql|SHOW TABLES LIKE 'vw_groups'|not_empty|
|
||||||
|
9037|2023_01_22_add_name_index.sql||show index from bot_data WHERE key_name = 'name`|empty|
|
||||||
|
|
||||||
# Upgrade conditions:
|
# Upgrade conditions:
|
||||||
# This won't be needed after this system is implemented, but it is used database that are not
|
# This won't be needed after this system is implemented, but it is used database that are not
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
create index `name` on bot_data(`name`);
|
||||||
@ -173,13 +173,23 @@ bool BotDatabase::QueryNameAvailablity(const std::string& bot_name, bool& availa
|
|||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format(
|
||||||
"SELECT b.bot_id FROM bot_data b "
|
"SELECT b.bot_id FROM bot_data b "
|
||||||
"INNER JOIN character_data c ON b.`name` = c.`name` "
|
"WHERE b.`name` LIKE '{}' "
|
||||||
"WHERE b.`name` LIKE '{0}' OR c.`name` LIKE '{0}' "
|
|
||||||
"LIMIT 1",
|
"LIMIT 1",
|
||||||
bot_name
|
bot_name
|
||||||
);
|
);
|
||||||
|
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
if (!results.RowCount()) {
|
||||||
|
query = fmt::format(
|
||||||
|
"SELECT c.id FROM character_data c "
|
||||||
|
"WHERE c.`name` LIKE '{}' "
|
||||||
|
"LIMIT 1",
|
||||||
|
bot_name
|
||||||
|
);
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
}
|
||||||
|
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user