Firestore的索引计入吗?

huangapple go评论66阅读模式
英文:

Does the index in Firestore count?

问题

我读到每次查询时都会自动创建一个索引。所以如果我创建了这个查询:

db.collection("users").whereEqualTo("admin", true);

并且我得到了一个结果,是否会为 admin 属性创建一个索引?如果是的话,这会占用文档配额吗?

英文:

I've read that for every query an index is automatically created. So if I create this query:

db.collection("users").whereEqualTo("admin", true);

And I get one result, is an index created for admin property? If yes, does this take space from the document quota?

答案1

得分: 1

查询不占用文档的空间。文档的空间位于用户集合下的文档本身中;每个文档都有自己的大小,且这个大小不会受到每个字段的索引的影响。

索引是为与查询匹配的文档创建的,但只有在满足条件的情况下访问的文档会计费。

根据文档

每个查询背后都有一个索引 如果没有针对查询的索引,大多数数据库将逐项遍历其内容,这是一个缓慢的过程,随着数据库的增长而变得更慢。Cloud Firestore通过为所有查询使用索引来保证高查询性能。因此,查询性能取决于结果集的大小,而不取决于数据库中的项数。

较少的索引管理,更多的应用程序开发 Cloud Firestore包含可减少管理索引所需时间的功能。为最基本的查询所需的索引会自动为您创建。随着您使用和测试应用程序,Cloud Firestore会帮助您识别并创建应用程序所需的其他索引。

英文:

The query does not take space for the document. The space of the document is in the document itself below your users collection; each document will have its own size, and this size will not be affected with the index for each field

The index is created for the documents your query matches, but you are only billed for the documents you access with that condition only.

From documentation:

> An index behind every query If no index exists for a query, most
> databases crawl through their contents item by item, a slow process
> that slows down even more as the database grows. Cloud Firestore
> guarantees high query performance by using indexes for all queries. As
> a result, query performance depends on the size of the result set and
> not on the number of items in the database.
>
> Less index management, more app development Cloud Firestore includes
> features that reduce the amount of time you need to spend managing
> indexes. The indexes required for the most basic queries are
> automatically created for you. As you use and test your app, Cloud
> Firestore helps you identify and create additional indexes your app
> requires.

huangapple
  • 本文由 发表于 2020年4月6日 19:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/61058997.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定