Courseiva
Performance →mediumMultiple Choice

SF-PD2 Performance Practice Question

A developer is building an Apex batch class that processes 2 million Account records. The start method uses the following SOQL query: [SELECT Id, Name FROM Account WHERE BillingCountry = 'US']. The query is selective because BillingCountry is indexed. However, during testing, the batch job fails with a 'First error: Apex CPU time limit exceeded' error. The developer suspects that the issue is related to the query performance. Which of the following is the most likely cause of the CPU timeout?

⚠ Common exam trap

The trap here is assuming that a selective query prevents CPU timeouts, when the real issue lies in the processing logic within the batch execute method.

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 execute method contains inefficient code, such as nested loops or excessive DML operations, causing high CPU usage per record.

The CPU timeout is caused by inefficient processing in the execute method, not the query. The query is selective and returns only necessary fields. With millions of records, nested loops, multiple DML calls, or complex calculations can exceed the CPU limit. The developer should optimize the execute method by reducing operations per record, using collections efficiently, and minimizing DML.

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 is returning too many fields, causing excessive heap size and indirectly CPU timeout.

    Why it's wrong here

    While heap size can be an issue, the error is specifically CPU time limit exceeded, not heap size. Querying only Id and Name is minimal. Heap size would not directly cause a CPU timeout; it would cause a 'Heap size limit exceeded' error. The CPU issue is due to processing logic, not the number of fields.

  • ✓

    The execute method contains inefficient code, such as nested loops or excessive DML operations, causing high CPU usage per record.

    Why this is correct

    The CPU timeout occurs during execution, not querying. Inefficient code in the execute method, such as nested loops, multiple DML statements per record, or complex calculations, can consume excessive CPU time. With 2 million records, even small inefficiencies are amplified. Optimizing the execute method is the correct fix.

  • ✗

    The query is not selective enough, causing a full table scan.

    Why it's wrong here

    BillingCountry is indexed and the query is selective, so a full table scan is unlikely. The CPU timeout is not due to query selectivity but rather the volume of records processed in the execute method. The query itself is efficient, but processing 2 million records in a single batch without proper chunking can cause CPU issues.

  • ✗

    The batch size is set to the default of 200, causing too many batches and excessive overhead.

    Why it's wrong here

    The default batch size is 200, but that would actually reduce CPU time per transaction because each batch processes fewer records. The error indicates CPU time exceeded, which is more likely due to processing logic within each batch, not the batch size. A smaller batch size would not cause a CPU timeout; it would mitigate it.

About these practice questions

This SF-PD2 question is part of Courseiva's 226-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.