Open YashJain24-chief opened 2 years ago
I am in favour of Approach 3, small to medium docs usually take less than 50ms. I think by the time we get to so large collection sizes that it starts exceeding, we would have migrated to better infrastructure or could do so quickly.
https://github.com/Real-Dev-Squad/todo-action-items/issues/77
Approach 1
When a new task is created, update the counter by reading from and writing to the taskCounter collection that will store the previous value of the counter.
Pros
Cons
Approach 2
Getting QuerySnapshot of the task collection and using size property
Pros
Cons
Approach 3
Using the
count
aggregation query.Pros No need to read and write to the firestore every time. It will basically return the number of documents in a collection which can then be incremented and stored when a new task is created. We are charged a small number of reads for a large number of matched entries.
Cons If a count() aggregation cannot resolve within 60 seconds, it returns a DEADLINE_EXCEEDED error. Performance depends on the size of the dataset.
Also what happens to the tasks that are already in the DB? How do we have a task number for those tasks?