Reputation: 179
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?
Upvotes: 0
Views: 269
Reputation: 13129
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.
Upvotes: 1