[英]Does whereIn in firebase query efficient?
有一個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.