Bird
0
0

What will be the result of this Firestore query?

medium📝 Predict Output Q5 of 15
GCP - Cloud Firestore and Bigtable
What will be the result of this Firestore query?
db.collection('orders').where('status', '==', 'delivered').orderBy('date')

Assuming no composite index exists for 'status' and 'date'.
AThe query will fail and prompt to create a composite index.
BThe query will ignore the orderBy and only filter by status.
CThe query will succeed and return filtered and ordered results.
DThe query will return all documents unordered.
Step-by-Step Solution
Solution:
  1. Step 1: Check if composite index is needed for equality filter + orderBy

    Firestore automatically creates single-field indexes for equality filters and orderBy on different fields.
  2. Step 2: Determine if query runs without composite index

    Since only one equality filter and one orderBy, no composite index is needed; query runs successfully.
  3. Final Answer:

    The query will succeed and return filtered and ordered results. -> Option C
  4. Quick Check:

    Equality + orderBy on different fields works without composite index [OK]
Quick Trick: Equality filter + orderBy usually no composite index needed [OK]
Common Mistakes:
  • Assuming composite index always needed with orderBy
  • Confusing equality and inequality filter rules
  • Ignoring Firestore's automatic single-field indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes