在火库查询中是否有效?
当我想要有关该特定用户的所有订单的信息时,我会使用这些ID从Collection 订单
获取数据。通过使用其中,
List<String> orderIds = (await FirebaseFirestore.instance
.collection('')
.doc(QnRWjhJbjViKUEVBvRAr)
.get()).get('orders');
var result = FirebaseFirestore.instance
.collection('orders')
.where(FieldPath.documentId, whereIn: orderIds)
.get();
我只是好奇。 <代码>其中 effiecient吗?它是否检查订单
中的每个文档,并测试该ID是否在OrderIDS
中?如果是这样,那么当有更多数据(假设数百万)时,这是否会出现性能问题吗?
I design a data model like this
there a users
collection that has one field store array of order ids.
When I want information about all orders of that specific user, I use these ids to get data from collection orders
. by using 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();
I just curious. Is whereIn
effiecient? Does it check every single document in orders
and test if that id is in orderIds
? If that true, when there're more data (let say millions) doesn't this will have performance issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Firestore具有非常清晰的性能保证:获得结果仅取决于您检索到的数据,并且完全独立于收集中存在的文档数量。因此,不,其中
的性能
不取决于集合的大小。Firestore has a very clear performance guarantee: getting results only depends on the data you retrieve and is completely independent of the number of documents that exist in the collection(s) queried. So no, the performance of
whereIn
doesn't depend on the size of the collection.