Question on optimization
#1

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!
Reply
#2

I often call a mysql query to get or check something and I also don't know this is good.
Reply
#3

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.
Reply
#4

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)
Reply
#5

Quote:
Originally Posted by GospodinX
Посмотреть сообщение
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)
If the query will be executed once(as loading a house from the database) that should be stored in an enum as its not gonna change so often as a player data. Same thing with server settings, if you gonna load the server settings doing once at the startup and store it somewhere in the server(enum or any other data structure). Also for server settings its not really need to be stored in the databse, they can be inside a .ini file and read it on the server startup and stored. Making changes inside the server and just query the database to update the player stats or something its better

In my opinion, i would query the database asking for changes only if the changes are coming from outside the server as a UCP/ACP change like grant a admin level to a player thought that ACP/UCP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)