Firestore document get() performance

前端 未结 1 912
青春惊慌失措
青春惊慌失措 2021-01-06 03:34

Just starting to explore Firestore storage and first thing to do - read a simple small document in my Android app by document key (authenticated with Google, but probably th

相关标签:
1条回答
  • 2021-01-06 03:46

    These get() requests are reading the data from the Cloud Firestore backend, over the network, so they'll necessarily be much slower than SQLite which is just reading locally from disk. The first read is also likely to be slower than subsequent ones since it has to initiate the network channel to the backend. We'll look at improving performance over time, but you can't expect 0 ms if you're retrieving data over the network.

    You may want to enable offline persistence which would enable local caching of data you've previously read. Note though that get() calls will still try to hit the network first to give you as up-to-date data as possible. If you use addSnapshotListener() instead, we'll call you immediately with the cached data, without waiting for the network.

    0 讨论(0)
提交回复
热议问题