What are Firestore composite indexes?

Answer

Composite indexes in Firestore are database indexes spanning multiple fields, required for queries that filter or order by more than one field. Firestore automatically creates single-field indexes for each field in every document. For compound queries — like where("category", "==", "shoes").orderBy("price") — Firestore needs a composite index on [category ASC, price ASC]. Without it, the query fails with an error containing a link to create the index. Index management: (1) Automatic — Firebase Console error link auto-populates the index creation form; (2) Manual — define in firestore.indexes.json and deploy with firebase deploy --only firestore:indexes; (3) Exemptions — disable single-field indexes for fields that don't need them (large array fields are expensive to index). Index limitations: maximum 200 composite indexes per database. Each index is billed as a write operation when documents are created/updated. Index propagation can take several minutes for large collections.