Question 358 of 1,000
Design and implement database schemasmediumMultiple ChoiceObjective-mapped

Firestore Composite Index for Boolean Field Queries

This PCDE practice question tests your understanding of design and implement database schemas. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A Cloud Firestore database stores documents for a mobile app. The app frequently queries for documents where a specific Boolean field is true. The field is not part of the collection group index. What should the developer do to improve query performance?

Quick Answer

The answer is to create a composite index that includes the Boolean field and the query ordering field. This is correct because Firestore’s automatic single-field indexes on a Boolean field only support simple equality filters; when you query for documents where a Boolean field is true and also apply an ordering or additional filter, the query engine cannot efficiently satisfy both conditions without a composite index that pairs the Boolean field with the ordering field. On the Google Professional Cloud Database Engineer exam, this scenario tests your understanding of how Firestore’s index merging works and the common pitfall of assuming single-field indexes are sufficient for filtered, ordered queries. A frequent trap is thinking denormalization or adding extra fields will solve performance issues, but without a proper composite index, the query will still scan all documents. Remember the memory tip: “Bool plus order, composite border” — whenever a Boolean filter meets an order clause, you need a composite index to cross that performance border.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Create a composite index that includes the Boolean field and the query ordering field.

Option B is correct because Cloud Firestore requires a composite index to efficiently query on a Boolean field combined with an ordering field. Without this index, the query would perform a full collection scan, leading to poor performance. Creating a composite index that includes the Boolean field and the query ordering field allows Firestore to use the index to directly locate matching documents, avoiding expensive sequential scans.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Add a synthetic field that combines the Boolean with a timestamp for range queries.

    Why it's wrong here

    A synthetic field might help but still needs an appropriate composite index.

  • Create a composite index that includes the Boolean field and the query ordering field.

    Why this is correct

    A composite index tailored to the query pattern improves performance and avoids full collection scans.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Denormalize the Boolean field into separate subcollections.

    Why it's wrong here

    This changes the schema structure and may complicate queries.

  • Rely on the automatic single-field index already created.

    Why it's wrong here

    Automatic indexing exists but for Boolean fields it may not be selective enough; composite index is better.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Candidates often assume that automatic single-field indexes are sufficient for all queries, but in Firestore, queries with both a filter and an order-by clause require a composite index, even if the filter is on a simple Boolean field.

Detailed technical explanation

How to think about this question

Under the hood, Firestore uses indexes to map indexed values to document locations. A composite index stores entries sorted by the first field (e.g., the Boolean field) and then by the second field (e.g., timestamp), enabling efficient filtering and ordering in a single index scan. In real-world scenarios, failing to create a composite index for queries with equality filters on one field and order on another can cause Firestore to fall back to a full table scan, which becomes increasingly slow as the collection grows, especially with millions of documents.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCDE practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Building and Implementing CI/CD Pipelines for a Service practice questions

Practise PCDE questions linked to Building and Implementing CI/CD Pipelines for a Service.

Bootstrapping a Google Cloud Organisation for DevOps practice questions

Practise PCDE questions linked to Bootstrapping a Google Cloud Organisation for DevOps.

Applying Site Reliability Engineering Practices to a Service practice questions

Practise PCDE questions linked to Applying Site Reliability Engineering Practices to a Service.

Implementing Service Monitoring Strategies practice questions

Practise PCDE questions linked to Implementing Service Monitoring Strategies.

Optimising Service Performance practice questions

Practise PCDE questions linked to Optimising Service Performance.

Plan and manage database infrastructure practice questions

Practise PCDE questions linked to Plan and manage database infrastructure.

Define data structures and implement SQL for Business Intelligence practice questions

Practise PCDE questions linked to Define data structures and implement SQL for Business Intelligence.

Design and implement database schemas practice questions

Practise PCDE questions linked to Design and implement database schemas.

Monitor and optimize database performance practice questions

Practise PCDE questions linked to Monitor and optimize database performance.

PCDE fundamentals practice questions

Practise PCDE questions linked to PCDE fundamentals.

PCDE scenario practice questions

Practise PCDE questions linked to PCDE scenario.

PCDE troubleshooting practice questions

Practise PCDE questions linked to PCDE troubleshooting.

Practice this exam

Start a free PCDE practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCDE question test?

Design and implement database schemas — This question tests Design and implement database schemas — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Create a composite index that includes the Boolean field and the query ordering field. — Option B is correct because Cloud Firestore requires a composite index to efficiently query on a Boolean field combined with an ordering field. Without this index, the query would perform a full collection scan, leading to poor performance. Creating a composite index that includes the Boolean field and the query ordering field allows Firestore to use the index to directly locate matching documents, avoiding expensive sequential scans.

What should I do if I get this PCDE question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More PCDE practice questions

Last reviewed: Jul 4, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDE exam.