Modeling a game leaderboard with Firestore – limitations with monotonically increasing field?

  Kiến thức lập trình

I have a video game model where I have a User collection in Firestore where each document has a score field. I want to query to get all users sorted by their score, from highest score to lowest. To do this, I need to index the score field and then I can query all users sorted by their score.

The issue is that the documentation says to avoid creating documents with a monotonically increasing field, like a timestamp, at a very high rate. Does this limitation apply to my use case? Just like timestamps, the score fields are always increasing across documents. But unlike timestamps, the score fields increase at a staggered rate.

For example, one user may have their score go from 1 to 2 to 3 in a one minute period, while another users score may go from 4 to 5 to 6 in that same period of time. Some users play the game often so they may have much larger scores that update more frequently than users who play less often.

Does the limitation to writing/updating documents with monotonically increasing fields apply to my use case?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT