I scanned Stack Overflow and the docs to reach to an optimal answer to this question. Answer to this question is important to adjust the skeleton of database. I looked to this answer from 2017, where he is talking about difficult and complicated methods to get the rank of a single user, which has led me think that maybe after 7 years, there have been some developments. When I look at this answer, he is telling that he made this by count()
function of firebase optimally. Then, when I tried to read how is the pricing for count()
function, I came across with this post, and this answer, where Frank says 1 document read for 1000 counted indexes. Also, I’ve read this docs and this, I couldn’t find an exact reply to count()
function’s clear pricing statement. What will be the pricing if there are 1 million documents to get counted, where there are queries of orderBy
, where
etc. ? Also, the second question is, is there an up-to-date price-friendly optimal method to get the rank of a single user in 1 million users?
Sample:
query(collection(db, "users"),
where(city, "==", user.city]),
orderBy("points", "desc"),
startAt("id", user.id)
count() // Maybe more efficient method than this can be advised.
12