Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simultaneous fetching of many documents from firestore #191

Closed
MarkChrisLevy opened this issue Oct 7, 2017 · 3 comments
Closed

simultaneous fetching of many documents from firestore #191

MarkChrisLevy opened this issue Oct 7, 2017 · 3 comments

Comments

@MarkChrisLevy
Copy link

MarkChrisLevy commented Oct 7, 2017

Describe your environment

  • Operating System version: OSX 10.13
  • Firebase SDK version: 4.5.0
  • Firebase Product: firestore

Describe the problem

I think that there is a serious issue with firebase-js-sdk of with firestore itself. In my I app I need to fetch data of multiple documents from different collections. Assume we have following structure: collection "customers", contains documents "customer" with subcollection "products" of "product" documents

Now, let say that I have list of customerId&productId pairs, which need to be fetched. I do loop over the list and for each pair I execute following:
firestore.doc("/customers/" + customerId + "/products/" + productId).get().then(data => console.log(data));

Now, if the list of documents is small the data are fetched in reasonable time, but when there are more than 20 documents to be fetched the data for all documents are delayed and it takes 30-60 seconds (depends how many documents to be fetched).

In real scenario I'm not using .get in a loop, but instead I use AngularFire2 and Observable.combineLatest - but the results are the same: when simultaneously fetching many documents, it causes huge delays of getting the data.

The same thing but using admin-node-sdk worked without any issues.

Steps to reproduce:

Call .doc 50 times in a row, e.g.:

for (let i = 0; i < 50; i++) {
    firestore.doc("/customers/" + i + "/products/" + i).get().then(data => console.log(data));
}
@MarkChrisLevy
Copy link
Author

MarkChrisLevy commented Oct 9, 2017

I made a test:
https://dev-test-17b7a.firebaseapp.com/

It does not happen all the time, but please try to reload few times and you will see, that second (or maybe other) test will take very long time to finish, in my case usually it looks like this:
Starting test #1
Test #1 finished in 2723ms
Starting test #2
Test #2 finished in 31317ms
Starting test #3
Test #3 finished in 1858ms
Starting test #4
Test #4 finished in 1997ms

Looking at the debug logs, you see the delay between following logs:

Firestore (4.5.0) 2017-10-09T13:37:19.216Z [Connection]: WebChannel received: {"targetChange":{"readTime":"2017-10-09T13:37:18.922733Z","resumeToken":"CgkI7afm0NTj1gI=","targetIds":[76]}}
firebase-firestore.js:15712 
Firestore (4.5.0) 2017-10-09T13:37:49.095Z [Connection]: WebChannel received: {"documentDelete":{"document":"projects/dev-test-17b7a/databases/(default)/documents/customers/9/test/9","readTime":"2017-10-09T13:37:48.979972Z","removedTargetIds":[78]}}

@firebase firebase deleted a comment from google-oss-bot Oct 19, 2017
@MarkChrisLevy
Copy link
Author

@tmk1991
Copy link

tmk1991 commented Jul 7, 2019

Is there a limit to how many queries you can fire off? What if I wanted to loop through and combineLatest 2000 times?
@MarkChrisLevy

@firebase firebase locked and limited conversation to collaborators Oct 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants