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

Quick Answer

The answer is that the query is slow because the Orders table is missing a secondary index on CustomerID. When a query filters on a column that is not part of the table’s primary key, Cloud Spanner cannot use its primary index to locate rows efficiently; instead, it must perform a full table scan across all splits, which becomes extremely slow as the table grows. On the Google Professional Cloud Database Engineer exam, this scenario tests your understanding of Cloud Spanner’s indexing architecture and the critical difference between primary and secondary indexes. A common trap is assuming the primary key order will help with arbitrary filter columns, but Cloud Spanner only leverages indexes that directly match the filter predicate. Remember the memory tip: “If it’s not in the key, you need a secondary index for speed.”

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.

Exhibit

CREATE TABLE Orders (
  OrderID INT64 NOT NULL,
  CustomerID INT64 NOT NULL,
  OrderDate DATE NOT NULL,
  TotalAmount NUMERIC NOT NULL,
) PRIMARY KEY (OrderID, CustomerID),
  INTERLEAVE IN PARENT Customers ON DELETE CASCADE;

A Cloud Spanner database contains the Orders table as defined above. The query `SELECT * FROM Orders WHERE CustomerID=123` takes a long time. What is the most likely reason?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1mediummultiple choice
Full question →

Exhibit

CREATE TABLE Orders (
  OrderID INT64 NOT NULL,
  CustomerID INT64 NOT NULL,
  OrderDate DATE NOT NULL,
  TotalAmount NUMERIC NOT NULL,
) PRIMARY KEY (OrderID, CustomerID),
  INTERLEAVE IN PARENT Customers ON DELETE CASCADE;

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

The table needs a secondary index on CustomerID.

The query `SELECT * FROM Orders WHERE CustomerID=123` filters on the `CustomerID` column, but the primary key of the Orders table is likely defined on a different column (e.g., `OrderID`). Without a secondary index on `CustomerID`, Cloud Spanner must perform a full table scan to find matching rows, which is slow for large tables. Creating a secondary index on `CustomerID` allows Cloud Spanner to directly locate the relevant splits and rows, dramatically reducing latency.

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 ORDER BY clause is missing.

    Why it's wrong here

    ORDER BY is not needed; the query is a simple filter, not a sort.

  • Interleaving causes extra I/O.

    Why it's wrong here

    Interleaving is for storing child rows with parents; it does not affect the performance of this query.

  • The primary key is not optimized for this query.

    Why it's wrong here

    While true, the primary key design is not the root cause; the absence of a secondary index on CustomerID is.

  • The table needs a secondary index on CustomerID.

    Why this is correct

    A secondary index on CustomerID enables direct lookup without scanning the entire table.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often assume a primary key is always the best way to query any column, but Cloud Spanner requires the query predicate to match the primary key order for efficient access; otherwise, a secondary index is necessary.

Detailed technical explanation

How to think about this question

Cloud Spanner uses a distributed, strongly consistent storage architecture where rows are partitioned into splits based on the primary key. A secondary index in Cloud Spanner is a separate table that maps indexed column values to the base table’s primary key; querying via the index avoids a full table scan by directly reading only the relevant splits. In practice, if the `CustomerID` column has high cardinality, a secondary index can reduce query latency from seconds to milliseconds, but it also adds write overhead and storage cost.

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: The table needs a secondary index on CustomerID. — The query `SELECT * FROM Orders WHERE CustomerID=123` filters on the `CustomerID` column, but the primary key of the Orders table is likely defined on a different column (e.g., `OrderID`). Without a secondary index on `CustomerID`, Cloud Spanner must perform a full table scan to find matching rows, which is slow for large tables. Creating a secondary index on `CustomerID` allows Cloud Spanner to directly locate the relevant splits and rows, dramatically reducing latency.

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.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

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: Jun 25, 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.