Does an indexed field in a subcollection have it's own index based on that subcollection (as opposed to the collection as a whole)?
For example, if I have a subcollection Review
like this: User/{documentId}/Review/
and it has an indexed field Integer createdAt
(a unix timestamp), will each Review
subcollection have its own 500 document write-per-second limit (because the timestamp is monotonically increasing)?
If so, is the path of the subcollection somehow used in the indexing of the createdAt
field to achieve this?
Alternatively, I was considering prefixing the documentId of the User
to the createdAt
timestamp in a new indexed field to help increase the write-per-second of all Review
subcollections for every User
like this: String userDocumentId+createdAt
But if the User
documentId (which is part of the whole path User/{documentId}/Review/
) is already being used for the indexed field under-the-hood, then maybe it won't make any difference?
Each and every collection and subcollection (and explicitly indexed collection group) is completely independent of each other for the purpose of the capabilities and limits of indexes. With this, one simply cannot affect another, so there would be no effect to any special design considerations for indexing.