小编use*_*936的帖子

firebase 管理员无法查询大项目

对于大型项目,使用 firebase admin 从云函数中的集合检索数据失败。我用来查询云函数选择的示例代码如下

admin.database().orderByChild('mmyyyy').equalTo(month).once('value');
Run Code Online (Sandbox Code Playgroud)

当我尝试检索 10600 个项目(试图找出原因)时,此调用失败。在谷歌控制台中有这个日志,但没有其他可以指出我正确的方向

textPayload:  "Function execution took 18547 ms, finished with status: 'response error'"   
Run Code Online (Sandbox Code Playgroud)

经过多次失败的尝试后,我决定尝试使用 firebase sdk 在客户端上执行此调用,如下所示:

result = await firebase.database().ref(`transactions`).orderByChild('mmyyyy').equalTo(month).once('value');
Run Code Online (Sandbox Code Playgroud)

这在客户端上完美运行,没有错误,并返回我的所有项目,其中 17000 个(该 json 的大小为 26MB)。

为什么会这样呢?是否有任何未记录的限制?

注意:我将云功能内存增加到 1GB,超时时间增加到 5 分钟,但没有帮助。

这是完整的示例代码

admin.database().orderByChild('mmyyyy').equalTo(month).once('value');
Run Code Online (Sandbox Code Playgroud)

firebase firebase-realtime-database google-cloud-functions firebase-admin

5
推荐指数
1
解决办法
2026
查看次数