繁体   English   中英

whereIn in firebase查询效率高吗?

[英]Does whereIn in firebase query efficient?

我这样设计一个数据model 在此处输入图像描述

在此处输入图像描述 有一个users集合,其中包含一个订单 ID 字段存储数组。

当我想要有关该特定用户的所有订单的信息时,我使用这些 ID 从收集orders中获取数据。 通过使用 whereIn

List<String> orderIds = (await FirebaseFirestore.instance
        .collection('')
        .doc(QnRWjhJbjViKUEVBvRAr)
        .get()).get('orders');
var result = FirebaseFirestore.instance
        .collection('orders')
        .where(FieldPath.documentId, whereIn: orderIds)
        .get();

我只是好奇。 whereIn吗? 它是否检查orders中的每个文档并测试该 id 是否在orderIds中? 如果那是真的,当有更多数据(比如说数百万)时,这不会有性能问题吗?

Firestore 有非常明确的性能保证:获取结果仅取决于您检索的数据,完全独立于查询集合中存在的文档数量。 所以不, whereIn的性能不取决于集合的大小。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM