question

Thomas Brown avatar image
Thomas Brown asked

When storing to player data (internal) which is better, multiple small key values or one key a lot of values?

So essentially I will be storing previous positions to my leaderboards in players internal player data. I'm curious what would be the better way to store them?

Player Data (Internal Data)

Option 1 (Leaderboard name to previous position map)

Key = Level 1 Completed Previous Position : Value = 131

Key = Level 2 Completed Previous Position : Value = 55

Key = Level 3 Completed Previous Position : Value = 200

Key = Level 4 Completed Previous Position : Value = 50

Key = Level 5 Completed Previous Position : Value = 400

Option 2 (Previous Positions key to json leaderboard name to previous position map)

Key = Previous Positions : Value = {
"Level 1 Completed":131

"Level 2 Completed":55

"Level 3 Completed":200

"Level 4 Completed":50

"Level 5 Completed":400

}

I'm primarily looking for pitfalls with key or value limits as well as best practices here. Also per usual whichever way would be best as far as cost goes would be great too.

Thanks in advance!

P.S. Here is some context for the question!

Player Data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gosen Gao avatar image
Gosen Gao answered

The Player Data elements are Key/Value pairs. The max Key size is 100 bytes. The max Value size is 300,000 bytes. And the player data updates per request is limited by 10. From this point of view and your scenario, it is better to store data in one key with a large value.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thomas Brown avatar image
Thomas Brown answered

I actually ended up storing my previous leaderboard position as key-value pairs per leaderboard instead of the suggested advice. This was because I was only going to update one leaderboard key-value pair per session.

Just wanted to chime back in just in case this helps someone else.

Also here is a picture of the limits @Gosen Gao is referring to.


limits.png (82.5 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.