How to get the length of a datastore

How do you get the length of a datastore space?

For instances, I’m trying to get to know how much data was found at the datastore. Let’s take an example with this datastore.

print(#game:GetService("DataStoreService"):GetDataStore("Testing_4234")) --// I know there is an error, but this can be changed differently
1 Like

This seems more like an XY problem. Why would you want to know the length of a datastore? Do you think there are users in your game losing data because there is simply too much being stored?

There’s no official method to finding the length of a datastore, but you might be able to find out with Crazyman32’s DataStore Editor, I would think.

1 Like

This isn’t possible since this would require a method to get all of the keys stored in the data store, which is not a feature. The feature on its own probably isn’t feasible because a DataStore doesn’t have a limit, causing a game with a lot of keys, like 1 per player for millions of unique players, to cause Roblox to freeze when creating a Lua version of the multi-million entry list from C++.

2 Likes

I tried to do the same thing recently, but there is no way I found so far.

Instead, I rewritten data into a new scope and used IncrementAsync to find out playerCount since.

1 Like

I like that idea of yours. Pretty much I would implement that idea to mine. Thanks!