How to avoid flooding DB queries

So I run store:SetAsync on 2 different storage’s with a ~second in between and Roblox is already complaining : “DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = Player_xxxx”. Should I just use different Keys :smiley: ?

1 Like

You’re saving every second? That’s very inefficient, I’d just save every few stat changes or when the server crashes/player leaves.

2 Likes

No, when player starts game I store stuff in 2 storage’s. Not every second, that would be insane.

2 Likes

Try using datastore2, I think they handle these errors for you.

Ehh. Do not really want to migrate to it at this point. Also it seems kind of alien.

Using different keys did not help. I guess I have to stick with the warning and ~1-2 sec delay.

It’s hard to assist without looking at your code.

I do know there is a 6 second limitation as to how frequently you can set keys, so that might be the case.

Most likely. Its just sad that this limitation seems to be per Game and not per storage. Because I set keys on different storage’s.

If they’re different keys the request limit is much larger per minute.

Like I said, it’s really hard to see what’s going on without peeking at your data store code

Why are you saving data across 2 keys? You can simply put data in a table and save it to 1 key.

You must understand that I can not share my whole project just like that. Its complex logic and the interesting lines are not just stack one after another. What I could do is try to replicate it in a simplified example. What I will do, if I find time for it. But generally I believe that if I just do:

local success, err = pcall(function()
		store1:SetAsync("banana", value)
	end)
wait(1)
local success, err = pcall(function()
		store2:SetAsync("banana", value)
	end)

I will get this error.

We are not asking for you to share your whole project, just the data store script.

There is no such thing as separate data store script for me. One thing is saved when player click “New game”, another when some conditions are met. The problem is that it sometimes happens in a second in between. I do know I can refactor my code, accumulate data and then store in one go. That’s not the advice I’m looking for. I thought there is some trick, to overcome the 6 second limit (could not find such info tho).

Ok I need to rethink my logic with this in mind (case closed):

But this is actually weird. It says 60*numPlayers*10 per minute for write requests, but in same time there needs to be 6 seconds between. I don’t see how both limitations can work hand in hand.

I’m pretty sure just changing the datastore name but using the same key doesn’t actually write to a new key in a new datastore it writes to the cached value of the key…not really sure how this works, but I’ve had issues with this in the past trying to erase data stores. Simply changing the datastore name didn’t work, you had to actually change the key in your get and set requests.

Does changing ‘banana’ to ‘banana2’ or something in one of your set requests change anything?

1 Like

Write requests are in total.

6 second delay is per-key.

You can only write to a key every 6 seconds.

1 Like

Yeah…

I was thinking to about the ‘erase store’ thing. Imagine that in early development and testing you write some trash data to data store and you need to erase it. Can’t! No way to get all keys and no way to purge data store by name. Such futures seem not to exist.The solutions are to place different names for data stores or keeping a special KEY data-store where to store keys :smiley: . It’s just so limiting in design that it makes me head-bang.

1 Like