Is it fine to have multiple datastores?

I have a question regarding if it is fine to have two Datastores for (PlayerData, PetData)?

[I use PlayerData to store values like Diamonds & Boolean values inside it] and I want to use PetData for storing Player's pets in it.

If it is not fine or necessary then should I create a table inside PlayerData called Pets instead of it having its own datastore?

--// Code, if it is fine to have multiple:
local PlayerData = DataStoreService:GetDataStore("PlayerData")
local PetData = DataStoreService:GetDataStore("PetData")

--[[ 
If it isn't good to have multiple datastores, should I create a table inside
the player's data called Pets?
--]]

local function newData()
	return {
		Stats = {
			Diamonds = 0,
			Stars = 0,
		},
		Challenges = {
			One = false,
			Two = false
		},
		Pets = {}
		}
	}
end
1 Like

It’s best to only use one datastore, and combine it all into one table, if you don’t you’re likely going to run into issues

only having to set and get from one datastore both reduces data loss and reduces throttling

so yes combine it under one table

6 Likes

It’s fine to have multiple DataStores but make sure to keep everything from limitations to better implementations in mind.

Typically you want to go with fewer DataStores so that you aren’t performing many requests and avoid throttling or potential data loss due to requests falling through. Ultimately though it falls down to why you think you need more than one DataStore. If you feel pet data does best separately to player data because they’re both going to be large, go right ahead.

Personal opinion but I would use a DataStore scope since pet data is related to player data and isn’t an entirely different data set. Two DataStores are fine but I’m just saying that I’d preference using a scope for consistency’s sake and whatever.

local PlayerData = DataStoreService:GetDataStore("PlayerData")
local PetData = DataStoreService:GetDataStore("PlayerData", "Pets")

(EDIT 05/10/2020): The above is outdated advice. Pets should now also be stored in the main DataStore without a scope because of the drastically increased storage limits. This post was made when values could only be 260K characters: values can now be 4M characters.

9 Likes