Currently, a game I am developing has 3 separate DataStores. One for Player’s stats, another for Player’s used-promo-codes, and one for Player’s currently-active-buffs. So I have something like this -
local CURRENT_SESSION = {}
local USED_CODES = {}
local TEMP_BONUSES = {}
Each of these Tables has a key set to the Player and the Value is a table containing all of the information related to that specific table. Instead of having to deal with 3 different DataStores and tables should I just create one main DataTable that holds all of the Player’s information including Stats, UsedCodes, and PromoCodes?
This is what I would make the main table look like if I were to combine them all into 1 DataStore/DataTable-
Basically, when saving Player’s data should I be trying to save everything related to that Player that requires saving within a single DataTable and if so, are there limits to doing this? And are there other ways or is this one of the best ways?
I have just recently begun looking a lot more into tables and I am beginning to see just how awesome they really are! I am very excited to learn more about them.
It is best practice to store all related data for a player in a table when possible. Each datastore itself does not have a maximum limit but the entry does, that is where you will be saving each player data, the maximum limit is 260,000 characters, but judging from what you are storing you can probably get away with storing all the data under one table. You can check the character length of you table by doing this:
local httpsService = game:GetService("HttpsService")
local dataTable = --put your data table here
print(string.len(httpsService:JSONEncode(dataTable)))
Also, it would be better to not use too many datastores. This is so because you dont want your requests getting throttled, this can happen because each game is only allowed a certain number of datastore requests (for example SetAsync and GetAsync) per minute based on the number of persons playing. You can read more about this at this link: Documentation - Roblox Creator Hub. In my opinion it would be best to use one table because judging from the data you are storing you will most likely not reach the 260,000 character limit and also it would reduce the number of times you have to use the datastore request functions. Although you will most likely never reach the limit, if you want to be sure you can compress your data by using this module here before saving Stravant's BitBuffer Module - Compact Storage Of Data [Tutorial].
It solely depends on who you ask… As this question as been asked before, the answer remains the same…
The more datastores, the more work the server has to do… If you have like 10+ datastores that may be a issue, but you also have to think about if you have 3 tables to save, all large… They might pass the size limit of a regular datastore… I’d say anything below 3 datastores is practical, anything below 5 is usable, and anything above 5 is dangerous…
You will just need to think about how much traffic your game receives and see how long it will take for you to reach the max size limit of a regular player’s data.