--
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 post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1eb89e52-18b1-4408-a12e-4ccba3c6c924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Sam,
Ok, thank you for a quick reply!
Jeff
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c5dad463-b8f5-4809-b474-2924c1a0d5c3%40googlegroups.com.
Thanks Sam.
Is there a way to test whether or not the data I'm retrieving is actually coming from the firestore index? I am not receiving the warnings about needing an index, but it is taking a long time to get the data.
It is taking a long time to retrieve data, and it takes longer the larger the dataset is... which is not supposed to happen with firestore.
Even if I use "limit" and keep the number of records the same.
For example, I create a query like:
Query query = fsDB.collection("Users").document(user_id).collection("posts").orderBy("date_created).orderBy("topic").limit(100)
Here are the results of some tests I did on my Android device:
If the "posts" collection has:
20 docs: 300-500 ms.
200 docs: 2000-3000 ms. , with one outlier of 6000 ms.
1200 docs: 3000-6000 ms.
5000 docs: 85000-95000 ms. on the first time I make the query, and had an outlier of 151000 ms. Immediate subsequent returns take only 30-60 ms. ! (I assume the device is accessing the cache?) But this does not happen for the earlier levels of tests (1200) for some reason.
Again, this is all using the "limit" feature. I also tried removing the "orderBy" elements, and the results are very similar.
Without the limit feature, it takes:
20 docs: 280 - 400 ms.
200 docs: 2500-3300ms, with averages closer to 3000ms.
1200 docs: 14,300 - 21,000ms, with an outlier of 23,000ms.
5000 docs:
The documents are really not very big, I don't think...
Using 'com.google.firebase:firebase-firestore:11.6.0'
Thanks,
Jeff
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/DM5PR2201MB10979C843DF87549F0683E24E8810%40DM5PR2201MB1097.namprd22.prod.outlook.com.
|
@izakfilmalter It would be helpful if you could be more specific about what exactly is taking longer and provide actual timing information rather than "a year." :-) Your comment about startup taking forever on spotty networks makes me wonder if you are doing As for startup taking longer with offline enabled, there's some known performance work in the pipeline. In particular, as you build up a large number of offline documents, even small queries may become slower as we do not yet implement indexing in the clients, so it has to scan all documents in the collection you're querying against. So that may explain what you're seeing. |
Hi Sam, Ok, thanks for clarifying that all firestore queries use an index.
Technically, I am actually using Firestore Recycler Adapter from the FirebaseUI, which uses .addSnapshotListener.
By the "limit feature" I meant using .limit().
Situation 1:
*User is connected to internet*Offline Persistence is enabled*5,000 documents in the user's "posts" collection
query = fsDB.collection("Users").document(user_id).collection("posts").orderBy("date_created).orderBy("topic")
It takes between 60 - 280 seconds for onDataChange to be executed (in other words, for the data to be received.)
Question 1) Isn't that excessively long to retrieve all 5000 of the documents? The documents are not very big. 15 key-value pairs per doc, just holding short strings.
Situation 2:
*User is connected to internet*Offline Persistence is enabled:
*5,000 documents in the user's "posts" collection
query = fsDB.collection("Users").document(user_id).collection("posts").orderBy("date_created).orderBy("topic").limit(100);
It takes an average of 90 seconds to retrieve the 100 documents from the 5,000 doc collection the first time it is tried. Every subsequent request is about 50 ms.
I assume that this is because the first return is writing those documents in the cache. The subsequent 50ms return is because the data is in the cache or memory.
Question 2) Why does the first request take so long, when I am limiting the retrieval to the first 100 documents by .limit(100)?
Question 3) This behavior - long first return, super fast subsequent returns - did not happen with tests where the "posts" collection had 20, 200, or 1,200 documents. In those tests, the return value stayed relatively consistent. In other words, for 1,200 docs, the return times would be 3-5 seconds, which seems long, considering I was using .limit(100). Why is the behavior different when I tested for 5,000 docs?
Situation 3:
*User is connected to internet*Offline Persistence is disabled*5,000 documents in the user's "posts" collection
query = fsDB.collection("Users").document(user_id).collection("posts").orderBy("date_created).orderBy("topic").limit(100);
Here, the fetch of 100 docs takes 2-3 seconds! So, in this situation we are using the index. I also just read that mike lehen, on Jan. 13, said that firestore does not support indexes on the client... so, what I think is happening is that with .addsnapshotlistener(), my device is checking the client device first, then sorting through the client side documents (since there is no index) before returning the data.
Here is his post:
@izakfilmalter It would be helpful if you could be more specific about what exactly is taking longer and provide actual timing information rather than "a year." :-)
Your comment about startup taking forever on spotty networks makes me wonder if you are doing
get()calls. We implement get() to get up-to-date data from the backend when online, else fall back to cache. So that could explain the issue and could likely be worked around by using onSnapshot() instead. We're also reworking some timeouts in the future which could help.As for startup taking longer with offline enabled, there's some known performance work in the pipeline. In particular, as you build up a large number of offline documents, even small queries may become slower as we do not yet implement indexing in the clients, so it has to scan all documents in the collection you're querying against. So that may explain what you're seeing.
Question 4) Is Firebase going to build the indexes on the clients as well?
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/DM5PR2201MB10976C1886C17737E05E1A18E8870%40DM5PR2201MB1097.namprd22.prod.outlook.com.
Hi Sam,
Thanks, will do ASAP. Sorry have been and will be a little busy with something else next week, but will be as engaged as I can with this, really appreciate your help.
Jeff