firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

FR: Better documentation for offline cache performance issues.

Open InputNeuron opened this issue 5 years ago • 1 comments

[REQUIRED] Describe your environment

  • Operating System version: all
  • Browser version: chrome
  • Firebase SDK version: 8 + 9
  • Firebase Product: firestore

[REQUIRED] Describe the problem

We use Firestore offline caching to optimize the performance of our application but also to provide offline support.

The issue is that, locally, Firestore doesn't provide any indexes and performance can be pretty bad at times.

We've made some changes to the design of our app due to some bad assumptions in the past. For example, we used to store binary data in firestore as images stored in JSON. It seemed to make sense because they were data in HTML content but it just ends up clogging Firestore.

It also seems that Firestore has an O(N^M) scalability issue where N is the number of snapshots and M is the amount of data.

I'm curious if we could alleviate the N^M issue by having just one snapshot listener per collection, then push this down into the root of my app, then have hooks fire later deep in my app that needs to subscribe / consume the data.

Also, if no indexes are used would there be any scanning of the underlying data or would the performance here be decent?

I'd basically like to JUST have Firestore store data in the cache as raw / efficiently as possible by making its job easier and avoiding any of the downsides.

We'd like to scale Firestore to LOTS of data and don't mind reading it into memory. We might have users that have >= 200MB of data but that would be a MASSIVE amount of content.

We just need some documentation for how to make that happen without having to fully analyze all the internals of Firestore.

InputNeuron avatar Nov 23 '21 14:11 InputNeuron

Hi @burtonator

Thanks for the request. Yeah, you are right the indexeddb cache does not having indexing, and performance can be weak with large amount of data.

I have plans to address this issue in the future, and this space is up for change. Will make sure we have some form of documentation once we are in a better place.

wu-hui avatar Nov 23 '21 16:11 wu-hui