SA-MP Forums Archive
MySQL query: What is faster? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Discussion (https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: MySQL query: What is faster? (/showthread.php?tid=360954)



MySQL query: What is faster? - FireCat - 19.07.2012

Well, I was scripting, and suddently something came to my mind, what would be faster:
Calling 2 query's
pawn Code:
function SaveStats(playerid)
{
    static Query[180];
    format(Query,sizeof Query,"UPDATE `Accounts` SET `Money` = '%i', `Score` = '%i', `Kills` = '%i', `Deaths` = '%i', `Arrests` = '%i', `Robs` = '%i', `Wantedlevel` = '%i' WHERE `Username` = '%s' LIMIT 1",
    GetPlayerMoney(playerid),
    GetPlayerScore(playerid),
    PInfo[playerid][Kills],
    PInfo[playerid][Deaths],
    PInfo[playerid][Arrests],
    PInfo[playerid][Robs],
    GetPlayerWantedLevel(playerid),
    GetPName(playerid));
    mysql_query(Query);
   
    format(Query,sizeof Query,"UPDATE `Accounts` SET `Jailed` = '1', `Jailtime` = '%i' WHERE `Username` = '%s' LIMIT 1",
    PInfo[playerid][Jailtime],
    GetPName(playerid));
    mysql_query(Query);
    return 1;
}
Or Making it all in 1 query but creating more cells?
IE, instead of static Query[180];, putting static Query[280];
What would be faster?


Re: MySQL query: What is faster? - IstuntmanI - 19.07.2012

Only one query, with more cells.


Re: MySQL query: What is faster? - Mauzen - 19.07.2012

The process to receive, respond to and handle a query already takes a lot of time, processing it is just a relatively short job. MySQL is designed to be able to take a lot of queries, but I guess because of all those things "around" the query a single one will be faster.


Re: MySQL query: What is faster? - Kiets - 19.07.2012

I don't think there should be a big difference. Just guessing, in my server there are a lot queries sent and it doesn't lag at all.


Re: MySQL query: What is faster? - FireCat - 19.07.2012

Quote:

[19:37:36] [join] Firecat has joined the server (0:*.*.*.*)
[19:38:10] 2 Queries took 30352 ms
[19:38:25] 1 Query with more cells took 15019 ms
[19:38:25] [part] Firecat has left the server (0:1)

I guess I have my answer :P
Edit: I tested it with 300 queries


Re: MySQL query: What is faster? - FireCat - 19.07.2012

Quote:
Originally Posted by Y_Less
View Post
Two queries are half the speed of one - funny that...
It makes sense...


Re: MySQL query: What is faster? - ReneG - 19.07.2012

Quote:
Originally Posted by Y_Less
View Post
Two queries are half the speed of one - funny that...
What?
Code:
[19:38:10] 2 Queries took 30352 ms
[19:38:25] 1 Query with more cells took 15019 ms
I'm guessing that was a mistake.

EDIT didn't see firecat's updated post.


Re: MySQL query: What is faster? - FireCat - 19.07.2012

Quote:
Originally Posted by VincentDunn
View Post
What?
Code:
[19:38:10] 2 Queries took 30352 ms
[19:38:25] 1 Query with more cells took 15019 ms
I'm guessing that was a mistake.

EDIT @FireCat - you should post the code you used. 30352ms is about 30.5 seconds...
I know... -_-


Re: MySQL query: What is faster? - SuperViper - 19.07.2012

Quote:
Originally Posted by VincentDunn
View Post
What?
Code:
[19:38:10] 2 Queries took 30352 ms
[19:38:25] 1 Query with more cells took 15019 ms
I'm guessing that was a mistake.

EDIT @FireCat - you should post the code you used. 30352ms is about 30.5 seconds...
Quote:
Originally Posted by FireCat
View Post
I tested it with 300 queries
4char.


Re: MySQL query: What is faster? - TheArcher - 25.07.2012

Quote:
Originally Posted by SuperViper
View Post
4char.
He has print 2 Queries took 30352 ms and 1 Query with more cells took 15019 ms looks like the first query and the second took around 45000 ms of 300 queries.