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

Quick Answer

The answer is to add a composite index on the columns used in the WHERE clause and the ORDER BY clause. This is correct because a composite index allows MySQL to satisfy both the filtering and the sorting requirements in a single index scan, eliminating the costly 'Using filesort' and 'Using temporary' operations shown in the EXPLAIN plan. When the index covers the ORDER BY columns, the database retrieves rows already in the correct order, dramatically reducing 'rows_examined' compared to 'rows_sent' and speeding up LIMIT queries. On the Google Professional Cloud Database Engineer exam, this scenario tests your understanding of index design for query optimization, often appearing as a performance troubleshooting question where a single-column index exists but filesort remains. A common trap is adding separate indexes on each column instead of a composite one, which still forces a sort. Remember the memory tip: "Where first, then order" — always place the WHERE column first in the composite index, followed by the ORDER BY columns, to maximize index efficiency.

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.

You are responsible for a Cloud SQL for MySQL instance that supports a content management system (CMS). The application frequently performs SELECT queries with ORDER BY and LIMIT. Recently, the response time for these queries has increased. The database has 4 vCPUs and 15 GB memory. You check the slow query log and find many queries that are taking over 1 second. The 'rows_examined' is much higher than 'rows_sent'. The EXPLAIN plan shows 'Using filesort' and 'Using temporary'. There is currently an index on the column used in the WHERE clause but not on the ORDER BY columns. The table has 5 million rows. What should you do to improve query performance?

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

Add a composite index on the columns used in the WHERE clause and the ORDER BY clause.

Option D is correct because adding a composite index on the columns used in the WHERE clause and the ORDER BY clause allows MySQL to avoid the expensive 'Using filesort' and 'Using temporary' operations. With a covering index, the database can retrieve rows in the required order directly from the index, eliminating the need to sort the result set after filtering. This dramatically reduces 'rows_examined' and improves query response time for SELECT queries with ORDER BY and LIMIT.

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.

  • Increase the buffer pool size to 80% of memory.

    Why it's wrong here

    More memory improves caching but does not fix the missing index for sorting.

  • Disable the query cache to reduce overhead.

    Why it's wrong here

    Query cache is removed in MySQL 8.0 and does not affect filesort.

  • Remove the ORDER BY clause and sort the results in application code.

    Why it's wrong here

    This would increase application complexity and possibly send more data.

  • Add a composite index on the columns used in the WHERE clause and the ORDER BY clause.

    Why this is correct

    A covering index eliminates sorting and temporary table usage.

    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 adding more memory or disabling features like the query cache can solve performance issues, when the real problem is a missing or poorly designed index that forces filesort and temporary tables.

Detailed technical explanation

How to think about this question

When MySQL performs 'Using filesort', it creates a sort buffer in memory (or on disk if the result set is large) and sorts the rows after retrieving them, which is expensive for large tables. A composite index on (where_column, order_column) allows MySQL to use the index to both filter rows and retrieve them in the required order, leveraging the B-tree structure to avoid a separate sort phase. In MySQL, the 'filesort' algorithm can be optimized with the 'sort_buffer_size' parameter, but the most effective fix is to provide a proper index that satisfies the ORDER BY clause directly.

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: Add a composite index on the columns used in the WHERE clause and the ORDER BY clause. — Option D is correct because adding a composite index on the columns used in the WHERE clause and the ORDER BY clause allows MySQL to avoid the expensive 'Using filesort' and 'Using temporary' operations. With a covering index, the database can retrieve rows in the required order directly from the index, eliminating the need to sort the result set after filtering. This dramatically reduces 'rows_examined' and improves query response time for SELECT queries with ORDER BY and LIMIT.

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.