googleapis / googleapis/google-cloud-node

Composite indices not created for aggregate queries

Open
#7,469 1 comment 0 reactions 1 assignee Claimed by @cherylEnkidu View on GitHub
api: firestore library: nodejs-firestore priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

I'm using the new [pre-GA aggregate query](https://cloud.google.com/firestore/docs/query-data/aggregation-queries) functionality. It's great so far.

I have a query as such:

```ts
db.subscriptions
.where("blogId", "==", blogId)
.where("status", "==", status)
.count()
.get()
```

(eg aggregating on two fields).

This was quite slow with a ~1-5m dataset and a <1k resultset. It was taking >1s for the query to execute.

I added a composite index on {blogId: asc, status: asc}, and it appears the query speed improved dramatically.

At no point did Firestore error out and prompt me to create the composite index (as it usually does). I wouldn't have known to do this other than just guessing.

It'd be great if Firestore provided a similar error message: "This query requires a composite index. Click here to create one."

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.