firebase / firebase/firebase-tools
Collection group query performance in Firestore emulator
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:** 10.1.2
**Platform:** macOS Monterey version 12.1
### [REQUIRED] Test case
### [REQUIRED] Steps to reproduce
1. Create a collection with many documents (35k documents in my case), containing a field that has an array of strings in it.
2. Run array-contains-any query against this collection group to get an error and create an index from the error message for the collection group.
3. Run query against production firestore, performance is in milliseconds as it should be.
4. Run firebase firestore:indexes > ../firestore.indexes.json in firebase root folder
5. Add to firebase.json:
```
//firebase.json
"firestore": {
"indexes": "firestore.indexes.json"
},
```
6. Start firebase emulator and run query, it takes around 15 seconds in my case.
```
//firestore.indexes.json
{
"indexes": [],
"fieldOverrides": [
{
"collectionGroup": "allIcons",
"fieldPath": "tags",
"indexes": [
{
"order": "ASCENDING",
"queryScope": "COLLECTION"
},
{
"order": "DESCENDING",
"queryScope": "COLLECTION"
},
{
"arrayConfig": "CONTAINS",
"queryScope": "COLLECTION"
},
{
"arrayConfig": "CONTAINS",
"queryScope": "COLLECTION_GROUP"
}
]
}
]
}
```
### [REQUIRED] Expected behavior
To have similar execution speed with indexes picked up
### [REQUIRED] Actual behavior
Indexes are not picked up in the emulator but work in production.
Contributor guide
Assessment
This issue has not been assessed yet.