[CLOUD_FIRESTORE] Long fetching time of data in local cache

未关闭
#7,914 9 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@dconeybe 已经在做这个了。

开始于 2026年3月16日。

评估

这个 Issue 还没有评估数据。

描述

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.

主要语言
Java
星标
2.6k
派生
733
平均合并
2 天 15 小时
30 天内合并 PR
72

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-android-sdk 的其他 Issue

查看 firebase/firebase-android-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。