Question 132 of 503
Monitor and optimize database performancemediumMultiple ChoiceObjective-mapped

Quick Answer

The answer is a missing composite index on (author, timestamp). This is the likely cause because when a Firestore query filters on one field and orders by another, it requires a composite index covering both fields to avoid a high number of document reads. Without it, Firestore must scan all documents matching the author filter, then sort them in memory, resulting in excessive reads and poor performance. On the Google Professional Cloud Database Engineer exam, this scenario tests your understanding of Firestore index behavior and query optimization, often appearing as a trap where single-field indexes seem sufficient but are not for combined filter-and-sort operations. A common memory tip is to remember that any query using both a where clause and an order by on different fields demands a composite index—think “filter plus sort equals composite.”

PCDE Monitor and optimize database performance Practice Question

This PCDE practice question tests your understanding of monitor and optimize database performance. 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 Firestore database is used for a social app. A collection of posts has indexes on fields `author` and `timestamp`. The query `where author == 'user1' order by timestamp desc limit 10` is performing a large number of document reads. What is the likely cause?

Question 1mediummultiple choice
Full question →

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

Missing composite index on (author, timestamp).

The correct answer is D because the query filters on `author` and orders by `timestamp`, which requires a composite index on `(author, timestamp)` to avoid a full scan. Without this composite index, Firestore must scan all documents matching `author == 'user1'` (or all posts if no single-field index on `author` is used) and then sort them in memory, leading to excessive document reads. The existing single-field indexes on `author` and `timestamp` are insufficient for this combined filter and sort operation.

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.

  • The limit is too high.

    Why it's wrong here

    Limit is only 10; the high read count indicates inefficient query execution, not limit size.

  • The query is scanning all posts.

    Why it's wrong here

    With proper composite index, the query would not scan all posts; this is a symptom, not the cause.

  • Index on timestamp is not descending.

    Why it's wrong here

    Even if the timestamp index is ascending, a composite index is still required; a single index on timestamp with descending order does not cover the equality filter on author.

  • Missing composite index on (author, timestamp).

    Why this is correct

    A composite index covers both the filter and sort, avoiding large scans.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Google Cloud often tests the misconception that single-field indexes are sufficient for combined filter and order queries, when in fact Firestore requires a composite index to avoid scanning all matching documents.

Detailed technical explanation

How to think about this question

Firestore uses composite indexes to efficiently support queries that combine equality filters on one field with an order on another; without one, it falls back to scanning all documents that match the equality filter and sorting them in memory, which can be costly for large datasets. Under the hood, Firestore's query planner checks for an index that matches the exact fields and order of the query, and if missing, it performs a 'collection group' scan or uses a single-field index with a client-side sort. In real-world scenarios, this often happens when developers add filters or sorts to existing queries without updating the index configuration, leading to unexpected read spikes and higher costs.

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.

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?

Monitor and optimize database performance — This question tests Monitor and optimize database performance — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Missing composite index on (author, timestamp). — The correct answer is D because the query filters on `author` and orders by `timestamp`, which requires a composite index on `(author, timestamp)` to avoid a full scan. Without this composite index, Firestore must scan all documents matching `author == 'user1'` (or all posts if no single-field index on `author` is used) and then sort them in memory, leading to excessive document reads. The existing single-field indexes on `author` and `timestamp` are insufficient for this combined filter and sort operation.

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

Last reviewed: Jun 30, 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.