SA-MP Forums Archive
whats different between Cache:mysql_query and tquery? - 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)
+--- Thread: whats different between Cache:mysql_query and tquery? (/showthread.php?tid=601965)



whats different between Cache:mysql_query and tquery? - iLuXing - 29.02.2016

is tquery faster or safer?
sometime I dont want use tquery, beacause I dont need a callback or I just want query it and use it inline.
sorry for bad english, THX to replies.


Re: whats different between Cache:mysql_query and tquery? - Roozevelt - 29.02.2016

i don't know what you mean but safer it's faster


Re: whats different between Cache:mysql_query and tquery? - DRIFT_HUNTER - 29.02.2016

Im myself using old R6 plugin with mysql_query_callback, so answer is based on what i read in wiki.

Mysql qeury will wait for response before continuing further, while tquery will be executed in another thread, code will continue and when mysql server send response it will be passed to callback.

Basically tquery is better for performance as it will be threaded. Simple example is, you send mysql_query to mysql server, it takes 5 seconds to respond (lets say huge lag or something), in that 5 seconds until mysql server responds or plugin decides that request has timed out your server will be stuck and not doing anything, not even updating players positions and such...meaning players would see server lag. While with tquery, after calling that function, server continues with executing his code, and when mysql server responds you get all info in a callback.


Re: whats different between Cache:mysql_query and tquery? - iLuXing - 29.02.2016

Thank you.


Re: whats different between Cache:mysql_query and tquery? - iLuXing - 29.02.2016

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Im myself using old R6 plugin with mysql_query_callback, so answer is based on what i read in wiki.

Mysql qeury will wait for response before continuing further, while tquery will be executed in another thread, code will continue and when mysql server send response it will be passed to callback.

Basically tquery is better for performance as it will be threaded. Simple example is, you send mysql_query to mysql server, it takes 5 seconds to respond (lets say huge lag or something), in that 5 seconds until mysql server responds or plugin decides that request has timed out your server will be stuck and not doing anything, not even updating players positions and such...meaning players would see server lag. While with tquery, after calling that function, server continues with executing his code, and when mysql server responds you get all info in a callback.
Can I do this ??

Код:
forward checkPlayerAccount(name[], queried = 0);
public checkPlayerAccount(name[], queried = 0) {
	if(requeried == 0) {
		new query[128];
		mysql_format(mySQL, query, sizeof query, "SELECT * FROM `accounts` WHERE `name` = '%e' LIMIT 1", name);
		mysql_tquery(mySQL, query, "checkPlayerAccount", format[] = "sd", name[], 1);
	} else {
		// Do something..
	}
}



Re: whats different between Cache:mysql_query and tquery? - AmigaBlizzard - 29.02.2016

That would be a good idea, never thought of that.
Try it and find out if it works.

My guess is that it would work just fine.