Eduardo
Eduardo

Reputation: 1837

How to identify unused indexes in a Firebase Firestore?

I have an application that uses Firebase Firestore. This is a great platform and my application grows every day, as well as my indexes. However, I suspect that they have unnecessary indexes. But I don't know how to identify them.

Is there a way to find this out in the Firestore?

Upvotes: 18

Views: 1457

Answers (2)

Ciprian Morar
Ciprian Morar

Reputation: 1

Maybe this helps:

  1. Use the Firestore console to list all of your indexes.
  2. For each index, check the Usage column. If the usage is zero, then the index is not being used.
  3. You can also use the Firestore CLI to list all of your indexes and their usage.
  4. Once you have identified unused indexes, you can delete them to improve the performance of your application.
firebase firestore indexes list
firebase firestore indexes delete <index-name>

Upvotes: -5

geg
geg

Reputation: 4795

I'm not aware of an automated solution to identify unused indexes, but you only need an index for fields that are explicitly used in your queries (e.g. for sorting).

I'd manually delete indexes that you suspect aren't used. If you happen to delete one that's actually needed then you'll know immediately because Firestore will simply error when you make the query. The error message should contain a link to set up the required index.

https://firebase.google.com/docs/firestore/query-data/indexing

As you use and test your app, Cloud Firestore generates error messages that help you create additional indexes your app requires.

Upvotes: -5

Related Questions