Server side table vs database whats to prefer?

General question, I hope this is the right spot.

I made a script where potentially is stored every 3rd players vehicle (that is currently parked out, not all that are in a garage) in a Database.
In this table is stored the licenseplate, the dirtlevel and a servertime.

If a player is in the drivers spot of a vehicle he will trigger a querry every 5 to 15 seconds (can be adjusted) to look up if the car is in the DB.
If yes, return the stored time and dirtlevel. If the time is smaller than the current servertime it will delete the entry.
If the time is greater it will replace the stored time. Also if the dirtlevel is less it will replace.

Now is my question: Would it be less load on the server if this was stored in a serverside lua table?
The DB Table clears itself on every script start. It does not have to be permanent.

I hope that I managed to phrase this understandable. :smiley:
Would be great if someone with knowlege would lighten me up! :+1:

I think it would be about the same load, if anything less when using the database as it is querying the db and not the table from the server, as well as using a database would be much easier I would assume, but not 100% sure

1 Like

theoretically speaking the table is faster, but we’re probably talking about milliseconds if not microseconds, but the database has a mess of other advantages, indicization, saving even to disk and more, so it is better the db

1 Like

If you are indeed clearing all info on script restart, then its better to use table server-side than playing around with MySQL.
As XenoS.exe says, DB has its advantages, but also disadvantages.
While it is usually very well optimized, then yeah there are ms delay from one another. But when transferring huge amount of data then its best to not use it or use it rarely.

For the purpose of your script with data clearing each time and no need to save the data, you should use tables instead of DB. Optimization with huge amount of traffic will be better in the long term. Even with small amount of traffic it will be better, less load = better!

1 Like

Thank you all for your answers. If I would stick to my initial approach I surely would use a serverside Lua Table now. But since I created this thread I removed the function of the cleansing in my script because it’s just a too much of an inconvenience for the players if the server does an unplanned restart and they lose their car-protection. :+1:

But it’s nice to have this information for future projects.