Posts: 256
Threads: 1
Joined: Aug 2014
Reputation:
0
Your question is pretty interesting. I'll tell you what I think, but maybe it's wrong. I'm sure somebody else will correct me if needed.
mysql_tquery processes the query on another thread, different than Pawn's main thread. Although, if one tquery is still processing, another tquery will have to wait for the first one to complete. On the other hand, mysql_pquery will send parallel queries, so if a query is keeping a thread busy, pquery will look for another free thread to do its job. The maximum number of threads that pquery will try to find is specified by that pool_size parameter of mysql_connect.
This is how I see it, maybe someone else will have another opinion.
Posts: 348
Threads: 26
Joined: Oct 2012
Reputation:
0
Thank you for your answer!
Okay, now I am getting the hang of it!
So, that pool_size is defined by the scripter?
I can put the value like 140?
EDIT: Are there any downsides by increasing the pool size?
Posts: 348
Threads: 26
Joined: Oct 2012
Reputation:
0
Never mind, I got it!
I can only use default pool size. 2 cores...
So in which situations should I use Parallel queries?
Also, can I get an anwser on EXTRA QUESTION?
Thank you!
Posts: 1,733
Threads: 20
Joined: Nov 2010
Reputation:
0
Mostly tqueries should do fine.
pqueries could be used when you're doing a MASSIVE query, which would take at least a few seconds to complete and you don't want other little queries to wait for the massive query to complete.
tqueries are put in a queue and are processed in the exact order you sent the queries.
So if your massive query would use a tquery, later queries will have to wait until that massive query has finished executing.
pqueries are processed at the same time and the first query could take more time than the second query, so the second query will be finished earlier.
There might be situations where this isn't wanted.
Sometimes you need one query to be finished first before the other so you send them right after eachother using tqueries.
Suppose you would use pqueries all the time and a new player logs in.
You ask for his password and you use a pquery to INSERT a new account into your database.
At the same time, you want new players to have a little starting cash, so you add another pquery to UPDATE his account with the given money.
Since an INSERT query takes more time, the UPDATE query will be finished earlier, but his account hasn't been created yet, so you will experience bugs.
The UPDATE query will fail as it can't find the account, then after this query failed, the account is added by the first query.
In such situations, you NEED to use tqueries as you need them to be executed in the exact order you sent the queries.
pqueries should only be used when you're doing a massive query which takes AT LEAST several seconds to complete.
Note that MySQL is pretty fast and such a query would need to gather ALOT of data, like 10.000+ rows.
I can't imagine any samp script would do such huge queries while the server is running.
Loading alot of data should be done before the server is online, and you can use mysql_query for those as well, so that you're certain your data is loaded before the server is opened up to the players, as mysql_query lets your script wait until the query is completed.
Posts: 1,733
Threads: 20
Joined: Nov 2010
Reputation:
0
It's there to indicate the end of the query, nothing more.
It's not really required, unless you want to send multiple queries in one line.
Posts: 348
Threads: 26
Joined: Oct 2012
Reputation:
0
Can't thank you more!
May your wishes come true!!!
Regards!