MySQL Query is to slow.
#1

Hello friends, i have a fuc* problem with my SQL Query, it takes 33sec to Upgrade the Admin column for 1 Player.


If i update the Admin Column for 500 players the server goes busy for nearly 20 sec, so the process takes up to 20sec...

if i remember right, sql saved once 500 players with lots of stuff in nearly 1sec.

idk what im doing wrong... i need some help...

PS: Im using StrickenKids SQL Plugin.

Code:
	#define Query(	format(sql, sizeof(sql), 
	new sql[512];
	new s = GetTickCount();
	Query("UPDATE Accounts SET Admin='5' WHERE Username='Cox'");
	mysql_query(sql);
	printf("Time used: %i", GetTickCount() - s);
Reply
#2

Do you use OnPlayerUpdate?
Reply
#3

What a question, srsly?

im using this as a test function in a command.


it just takes 30-50ms to execute the mysql_query(...) once, when i use this for like 500 players it will take up to 20 seconds...

it should be faster....
Reply
#4

First of all, you can insert that query raw straight in to mysql_query(), you don't need to waste your time creating useless macros.

Secondly, you're wasting 461 cells (which is 1,844 bytes of memory) formatting your query, that's just horrible.

Thirdly, try perform the query remotely, eg. through phpMyAdmin or whatever interface you have available.

Some additional tips:
If you're connecting to a remote MySQL server - that's probably your problem.
If you're constantly trying to send a million queries and you poorly optimize your code like so, that's probably your problem.
Reply
#5

again: this query is just a test, in my thread OnPlayerSave i nearly use all cells.

and im not connected to a remote MySQL Server, its a Local SQL Server running on the same system and im not sending constantly a million queries, its just 1 query to test.
Reply
#6

You probably have other queries running.
Reply
#7

no, this is a clean GM, im not that stupid trust me, its just a bit weird, in the phpMyAdmin cp it takes 0.001ms to execute that command but in SA:MP 40ms.

Server is running local, yes and there are no more query's in my gamemode.

i also put the string directly in the query function.

"mysql_query("UPDATE Accounts SET Admin = '1' WHERE Username = 'Cox');"

no change...
Reply
#8

Try G-StyleZzZ's plugin and see what the outcome is.
Reply
#9

still same result.

with gtsyle it takes up to 80ms to save...

idk what happend... it worked a half year for me i were able to save 500players in less then a second and now its fked up...

the normal sql query in the phpmyadmin site needs 0.01ms but in samp 30-120ms for the update query...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)