Courseiva
Performance →hardMultiple Choice

SF-PD2 Performance Practice Question

A developer is optimizing a complex SOQL query that joins multiple custom objects. The query is used in a trigger and is causing CPU time limit exceptions. The developer notices that the query is not using any indexes. What is the most likely cause?

⚠ Common exam trap

The trap here is assuming that any complex query automatically uses indexes, when in fact index usage depends on the fields in the WHERE clause.

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 query includes a WHERE clause on a field that is not indexed.

The most likely cause of a SOQL query not using an index is that the WHERE clause filters on a field without a custom index. This forces a full table scan, leading to high CPU consumption and potential governor limit exceptions. Adding a custom index on the filtered field can resolve the issue. Other options are either less common or do not directly explain the lack of index usage.

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 query uses a relationship subquery that exceeds the maximum allowed depth.

    Why it's wrong here

    While relationship subqueries have depth limits, exceeding them would result in a compile-time error, not a CPU time exception. The scenario states the query is not using indexes, which points to a missing index rather than a depth issue. Subquery depth limits are typically not the cause of CPU timeouts in triggers unless the query is extremely complex, but the explicit mention of no index usage is the key clue.

  • ✓

    The query includes a WHERE clause on a field that is not indexed.

    Why this is correct

    SOQL queries rely on indexes to efficiently filter records. If the WHERE clause references a field without a custom index, the query performs a full table scan, consuming excessive CPU time. This is especially problematic in triggers where CPU limits are strict. Adding a custom index on the filtered field can dramatically improve performance and prevent CPU time exceptions.

  • ✗

    The query is using a NOT operator in the WHERE clause.

    Why it's wrong here

    Using NOT in a WHERE clause can prevent index usage, but it is not the only cause. The scenario explicitly states the query is not using any indexes, and the most common reason is a missing index on a filtered field. While NOT can contribute, it is a specific case; the general cause is the absence of an index. The question asks for the most likely cause, and missing index is more fundamental.

  • ✗

    The query is selecting too many fields, causing high CPU usage.

    Why it's wrong here

    Selecting many fields increases the amount of data retrieved, which can affect performance, but it does not directly prevent index usage. The query optimizer chooses an index based on the WHERE clause, not the SELECT clause. So while selecting many fields can contribute to CPU time, it is not the reason the query is not using an index. The core issue is the filtering condition.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce 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 SF-PD2 exam.