Question 156 of 503

Quick Answer

The answer is to create a composite index on (date, account_id). This is correct because PostgreSQL cannot efficiently combine separate indexes on date and account_id for queries that filter by a date range and then group by account_id; the query planner often estimates that a sequential scan is cheaper than the overhead of a bitmap scan merging two indexes, especially on large tables. On the Google Professional Cloud Database Engineer exam, this scenario tests your understanding of index design and the query planner’s cost-based decisions—a common trap is assuming separate indexes are sufficient, but PostgreSQL requires a composite index to satisfy both the filter and the sort order in a single index scan. Remember the memory tip: “One index to rule them all”—when a query has both a WHERE and a GROUP BY, a composite index covering both columns in the correct order (filter first, then group) eliminates the need for separate sorts and bitmap scans, directly improving join performance in Cloud SQL PostgreSQL.

PCDE Practice Question: Define data structures and implement SQL for Business Intelligence

This PCDE practice question tests your understanding of define data structures and implement sql for business intelligence. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. 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 a cloud database engineer for a financial services firm. The firm uses Cloud SQL for PostgreSQL to support a BI reporting tool. The main table 'transactions' has 500 million rows and is growing daily. Reports often run aggregations over date ranges and group by account_id. The 'transactions' table has indexes on date and account_id separately. Despite these indexes, the reporting queries are slow, often taking over 30 minutes. The database is deployed on a high-memory machine with 32 vCPUs and 256 GB RAM. You notice that the queries perform sequential scans instead of using indexes. What is the most likely reason, and what single change would you make to improve performance?

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 1hardmultiple 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

Create a composite index on (date, account_id)

The correct answer is B because the reporting queries filter by date ranges and group by account_id, but the existing separate indexes on date and account_id cannot be combined efficiently for both conditions. PostgreSQL's query planner often chooses a sequential scan over using two separate indexes because it estimates that reading the entire table is cheaper than the bitmap scan overhead of combining them. A composite index on (date, account_id) allows the database to directly locate rows matching the date range and then access them in account_id order, eliminating the need for a separate sort or join step.

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.

  • Partition the table by date using PostgreSQL declarative partitioning

    Why it's wrong here

    Partitioning can help, but the queries already filter by date range; the main issue is the grouping by account_id, which a composite index addresses better.

  • Create a composite index on (date, account_id)

    Why this is correct

    A composite index that matches the query's WHERE and GROUP BY can drastically reduce the data scanned.

    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.

  • Increase the shared_buffers setting to 128 GB

    Why it's wrong here

    While larger buffers can help, they still require reading data into memory, and the optimizer might still choose a sequential scan if the query reads a large fraction of the table.

  • Disable sequential scans by setting enable_seqscan = off

    Why it's wrong here

    Forcing the query planner can lead to even worse plans; it's better to provide a proper index.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Google Cloud often tests the misconception that adding separate indexes on each column is sufficient for multi-column queries, but the trap here is that PostgreSQL cannot efficiently combine separate indexes for both filtering and grouping without a composite index that matches the query's access pattern.

Detailed technical explanation

How to think about this question

PostgreSQL's query planner uses cost-based optimization; a composite index on (date, account_id) supports both the WHERE clause filter (date range) and the GROUP BY (account_id) as an index-only scan if the index covers the query columns. Under the hood, PostgreSQL can use the index to retrieve rows in sorted order by account_id, avoiding an explicit sort step for the GROUP BY. In a real-world scenario with 500 million rows, a composite index can reduce query time from 30 minutes to seconds by eliminating full-table scans and external sorting.

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 company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

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?

Define data structures and implement SQL for Business Intelligence — This question tests Define data structures and implement SQL for Business Intelligence — 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 on (date, account_id) — The correct answer is B because the reporting queries filter by date ranges and group by account_id, but the existing separate indexes on date and account_id cannot be combined efficiently for both conditions. PostgreSQL's query planner often chooses a sequential scan over using two separate indexes because it estimates that reading the entire table is cheaper than the bitmap scan overhead of combining them. A composite index on (date, account_id) allows the database to directly locate rows matching the date range and then access them in account_id order, eliminating the need for a separate sort or join step.

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

Same concept, more angles

1 more ways this is tested on PCDE

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A company uses Cloud SQL for PostgreSQL for its BI database. Queries involving joins on large tables are slow. Which TWO strategies should they implement to improve join performance? (Choose TWO.)

medium
  • A.Denormalize tables to reduce the number of joins
  • B.Add indexes on the columns used in JOIN conditions
  • C.Increase the number of CPU cores on the instance
  • D.Create read replicas for the join queries
  • E.Use connection pooling to reduce connection overhead

Why A: Denormalizing tables reduces the number of joins required in queries by combining related data into fewer tables. This directly minimizes the computational overhead of join operations in Cloud SQL for PostgreSQL, which is especially beneficial for large BI datasets where join performance is critical.

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.