Jump to content
xjoker_

Performance question, database vs variables

Recommended Posts

Hello, 

 

Let's say I have a database , with like 5k players, 10k vehicles, 5xx groups... 

And i have to update those very often

Is it better to update directly in DB whenever it's needed (for example using extDB3), 

or to have server variables with a huge number of entries (arrays),

and when i want to update something i browse all these arrays, to find some players/objects IDs, update data in those variables, and then update the DB like every X minutes/hours with my variables ?

like some sort of "caching system"

Is there a limit for what you can store in a variable ?

Share this post


Link to post
Share on other sites
31 minutes ago, xjoker_ said:

Is there a limit for what you can store in a variable ?

There is a length limit for arrays. Also everything in variables has to stay in Ram, which you might not have that much of.

 

31 minutes ago, xjoker_ said:

and when i want to update something i browse all these arrays, to find some players/objects IDs

Database solutions are very optimized to allowing you to look up things very quickly. SQF is not. Not at all.

 

Storing values into variables costs basically nothing. In relation to a relatively expensive callExtension for extDB. So just storing into variables would be more performant.

Though looking up values might be harder.

Might aswell just use a Database mod that doesn't use extDB, like Intercept-DB (advertisement :U) which is about as fast to use as any native SQF code.

Share this post


Link to post
Share on other sites
1 hour ago, xjoker_ said:

Is there a limit for what you can store in a variable ?

for arrays its 9,999,999 elements for each array. source

Share this post


Link to post
Share on other sites

You can build an interface over your code, and schedule a flush all the 5 min

 

callextension as code execution time: dll + all layers to join db + db execution time.

Share this post


Link to post
Share on other sites

Why would you want to keep the whole db in sqf array? This makes no sense, you have max 120 people on the server, you can easily keep each player data that you need to update frequently on the server and send it to the database when player leaves or at some reg interval. 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×