0
0
GCPcloud~5 mins

Firestore queries and indexes in GCP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Firestore index and why is it important?
A Firestore index is a data structure that helps Firestore quickly find and sort documents based on query conditions. It is important because without proper indexes, queries can be slow or fail to run.
Click to reveal answer
intermediate
What types of queries require composite indexes in Firestore?
Queries that filter or sort on multiple fields at the same time require composite indexes. For example, querying where 'status' is 'active' and ordering by 'createdDate' needs a composite index.
Click to reveal answer
beginner
How does Firestore handle queries without an existing index?
Firestore returns an error with a direct link to create the required index in the Firebase console. This helps you quickly add the needed index for your query to work.
Click to reveal answer
intermediate
What is the difference between single-field and composite indexes in Firestore?
Single-field indexes are automatically created for each field and support simple queries. Composite indexes combine multiple fields and support complex queries with multiple filters or sort orders.
Click to reveal answer
advanced
Why should you avoid unnecessary indexes in Firestore?
Unnecessary indexes increase storage costs and slow down write operations because Firestore updates all relevant indexes when data changes. Keeping only needed indexes improves performance and reduces cost.
Click to reveal answer
Which Firestore query requires a composite index?
AQuery filtering by one field only
BQuery ordering by a single field
CQuery filtering by two fields and ordering by one
DQuery fetching all documents without filters
What happens if you run a Firestore query without the needed index?
AThe query returns an error with a link to create the index
BFirestore ignores the missing index and returns partial results
CThe query runs slowly but returns results
DFirestore automatically creates the index
Which index type is created automatically for each field in Firestore?
AComposite index
BNo index is created automatically
CFull-text index
DSingle-field index
Why should you limit the number of indexes in Firestore?
AIndexes increase storage costs and slow writes
BIndexes slow down read operations
CIndexes cause data loss
DIndexes prevent queries from running
Which Firestore query can run without any composite index?
AQuery filtering by two fields
BQuery filtering by one field only
CQuery ordering by two fields
DQuery filtering and ordering by multiple fields
Explain how Firestore uses indexes to speed up queries and what happens if an index is missing.
Think about how a book index helps you find pages fast.
You got /4 concepts.
    Describe best practices for managing Firestore indexes to balance performance and cost.
    Less clutter means faster work and lower bills.
    You got /4 concepts.