[CLOUD_FIRESTORE] Long fetching time of data in local cache

Aperta
#7,914 9 commenti 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dconeybe ci sta già lavorando.

Dal 16/3/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

api: firestore
[REQUIRED] Step 2: Describe your environment

Packages in Flutter project:

  • firebase_core: 4.4.0
  • cloud_firestore: 6.1.2 (corresponding to Firebase BoM 34.7.0)
[REQUIRED] Step 3: Describe the problem

We've noticed an issue with persistent storage in our Flutter project. Very similar to https://github.com/firebase/firebase-android-sdk/issues/7198#issuecomment-4045347626. It happens only on Android, I’m not able to reproduce it on iOS.
When we have a lot of cached data e.g. 5k records, then some specific queries need much more time to be executed e.g. 100ms vs 2s.

Here is an example of a query:

    final DateTime nowDateTime = DateTime.now();
    query = query
        .where('Dateandtime', isGreaterThanOrEqualTo: Timestamp.fromDate(nowDateTime))
        .where('Dateandtime',
            isLessThanOrEqualTo: Timestamp.fromDate(nowDateTime.add(const Duration(days: 7))));

Disabling persistence storage fixes the issue.
I also tried enabling automatic index creation and manually providing indexes, but I didn’t notice any significant difference.

Steps to reproduce:
  1. Fetch a list of items using Stream. It should return data very quickly.
  2. Persistence storage is enabled. Fetch ~5k random items.
  3. Execute the same query as in step 1. The execution time increases a lot.

Here is also a SQLite database with the state at which executing the above query takes ~2s instead of 200ms.
https://drive.google.com/file/d/1rP3hB6qSMjRqUshvmS7rMrNIhDJSXyqh/view?usp=sharing

cc: @dconeybe
If you won't be able to reproduce the issue let me know. I will try to help.

Lingua principale
Java
Stelle
2.6k
Fork
733
Merge medio
2g 15h
PR unite (30g)
72

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/firebase-android-sdk

Tutte le issue di firebase/firebase-android-sdk

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.