Posts: 147
Threads: 73
Joined: Jul 2013
Reputation:
0
Is it bad if I call a Mysql query every time I want to check on something I need or is storing the info inside enums a better practice. I also wish to know if the difference in performance is huge.
Thanks in advance!
Posts: 162
Threads: 37
Joined: Feb 2017
Reputation:
0
I often call a mysql query to get or check something and I also don't know this is good.
Posts: 111
Threads: 1
Joined: Sep 2017
Reputation:
0
You shouldn't do it EVERY TIME, you should store to variables at the launch of the server or once a player connects (depending on what it is you're checking) and then update the variables depending on what effects them i.e. if you want to check a players cash, when the player connects, store his cash from MYSQL to a variable, then update the variable whenever the players cash is effected, then check the variables, when the player disconnects, update the variables.
Somethings you can't really store to a variable and so reading from your database is the only option, if you're using a server host, depending on how much data you're reading, it shouldn't be noticeable, but if you're home hosting, it'll always be noticeable with server lag on anything over 10-20 rows.
Posts: 151
Threads: 47
Joined: Nov 2017
Reputation:
0
Hi ItsRobinson,
I also needed answer on this question,so thank you!
But i have other question.Ok,for players info(cash etc) are not good to call mysql query,I think that we all know it.(Because you will need to call it many times)
But what about houses,server settings and other things which don't need to be called often? Is there any thing which is better to don't store inside enums?
(Sorry for English)