Firestore has a limit of 500 wps per collection if a collection indexes sequential data field such as createdAt.
Consider a vote collection:
Vote { userId: string postId: string vote: 1 | 0 | -1 createdAt: Timestamp }Without any write limits, I can simply make vote collection a top level collection: /vote/{voteId}
However, this will limit my app to be able to handle only 500 votes per seconds across the entire app.
Which means it will not scale to the size of reddit or instagram where there are many many posts and votes happening all over those posts and comments.
To work around the limit, I am making vote collection a subcollection of post: /post/{postId}/vote/{voteId}
Now 500 wps limit only applies to each individual vote collection for each post, not across the app.
Is this assumption correct?
Now, I want to query votes by user who casted the vote.
For example, a user may want to see his/her previous votes.
I can make a collection group index on vote.userId (NOT in composite with vote.createdAt) field to do that.
How will this collection group index affect 500 wps limit now?
Will it bring it down to 500 wps across the app?
What if I make a collection group composite index on vote.userId and vote.createdAt?
How would you structure your collections for this common voting pattern if you want to scale it to the level of reddit in the future without migrating away from firestore?
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/380ee10e-90a3-4e72-93c7-5d1a8ecc52e4n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAHEiOC0duW7K39Fh9%2BP7pULjwSuTn4sYufHUHtP1CY8oCXLNTQ%40mail.gmail.com.