diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-12-15 00:37:38 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2011-12-15 00:37:38 +0000 |
commit | 4c6f057f3d40bd7aa8e7d65e672ade0ee26c4aa9 (patch) | |
tree | 938de35b0ad843ca37e7312a2723ed1b3e02a421 /src/char_sql/char.c | |
parent | 431fe4d07148d02f62d9ff8a3bd333ff9a71455e (diff) | |
download | hercules-4c6f057f3d40bd7aa8e7d65e672ade0ee26c4aa9.tar.gz hercules-4c6f057f3d40bd7aa8e7d65e672ade0ee26c4aa9.tar.bz2 hercules-4c6f057f3d40bd7aa8e7d65e672ade0ee26c4aa9.tar.xz hercules-4c6f057f3d40bd7aa8e7d65e672ade0ee26c4aa9.zip |
few MySQL Optimizations to char-server
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15125 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/char.c')
-rw-r--r-- | src/char_sql/char.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 9c3d5492d..4df1a58dd 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -242,7 +242,7 @@ void set_char_online(int map_id, int char_id, int account_id) struct mmo_charstatus *cp; //Update DB - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) ) + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) Sql_ShowDebug(sql_handle); //Check to see for online conflicts @@ -297,7 +297,7 @@ void set_char_offline(int char_id, int account_id) if (cp) idb_remove(char_db_,char_id); - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id) ) + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) ) Sql_ShowDebug(sql_handle); } @@ -814,7 +814,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit } if( !found ) {// Item not present in inventory, remove it. - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d'", tablename, item.id) ) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) ) { Sql_ShowDebug(sql_handle); errors++; @@ -1255,7 +1255,7 @@ int rename_char_sql(struct char_session_data *sd, int char_id) Sql_EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH)); // check if the char exist - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s'", char_db, esc_name) ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) ) { Sql_ShowDebug(sql_handle); return 4; @@ -1317,7 +1317,7 @@ int check_char_name(char * name, char * esc_name) } // check name (already in use?) - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s'", char_db, esc_name) ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) ) { Sql_ShowDebug(sql_handle); return -2; @@ -1361,7 +1361,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag } // check char slot - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d'", char_db, sd->account_id, slot) ) + if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d' LIMIT 1", char_db, sd->account_id, slot) ) Sql_ShowDebug(sql_handle); if( Sql_NumRows(sql_handle) > 0 ) return -2; // slot already in use @@ -1408,9 +1408,9 @@ int divorce_char_sql(int partner_id1, int partner_id2) { unsigned char buf[64]; - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, partner_id1, partner_id2) ) + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) ) Sql_ShowDebug(sql_handle); - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d')", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) ) + if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) ) Sql_ShowDebug(sql_handle); WBUFW(buf,0) = 0x2b12; |