13.07.2017, 10:50
Quote:
Using tquery you have one extra thread and all queries get pushed onto a queue in that one thread. So the queries get executed in the order they are received. With pquery on the other hand your query gets pushed onto a queue in any of the available threads so queries may not necessarily execute in the order they are received. The amount of threads that are available is the number you specified for "poolsize" in mysql_connect.
|
Use mysql_pquery to fetch a lot of data at the same time, like at player login. Imagine if you did a fresh server restart and suddenly dozens of users are logging in simultaneously. You'll probably see a performance improvement there if comparing to mysql_tquery.
For everything else you really should be using mysql_tquery, because of various performance-related reasons (mainly locks).
I did a small comparison between pquery and tquery, and got some nice results. (running MariaDB with InnoDB; script I've used + logs here; pool size = 4; table has 300k entries)
I've basically sent one big update query which was working without using the primary index, and three insert queries after that, each one creating three entries.
insert query time with tquery: steady ~4ms
insert query time with pquery: ranging from 4 - 10ms
More than doubled insert query execution time in the worst case. Moreover, you can speed up the tquery inserts by using a transaction, which takes down execution speed from ~12ms (3*4ms) to ~6ms. Transactions don't work with mysql_pquery, so there's nothing you could improve there.
That's a very synthetic example of course. You can use mysql_pquery and generally don't notice anything if you're running on good hardware. I've run that example on a PC with an SSD and a powerful CPU. 4 milliseconds more or less don't really mean anything. But if you really care for performance, use the advice I've given at the beginning: mysql_pquery to load a lot of data concurrently, mysql_tquery for everything else.