Courseiva
Performance →hardMultiple Choice

SF-PD2 Performance Practice Question

A developer is optimizing a Lightning Web Component that displays a list of 500 custom object records. The component uses a wire adapter to call an Apex method that returns the records. The Apex method currently queries all fields on the custom object, including several rich text fields and formula fields that are not displayed in the component. Users report that the component takes a long time to load. What should the developer do to improve the performance of the Apex method?

⚠ Common exam trap

The trap here is focusing on caching or limiting records as performance fixes, when the real issue is querying unnecessary fields that increase data transfer and computation.

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

✓

Use a SOQL query that selects only the fields required by the Lightning Web Component, avoiding unnecessary fields.

The Apex method is slow because it queries all fields, including expensive rich text and formula fields that are not displayed. Selecting only the required fields reduces the data volume and computation, improving performance. Caching or limiting records does not address the root cause and may alter functionality. The best solution is to optimize the SOQL query to fetch only the needed fields.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Use a SOQL query that selects only the fields required by the Lightning Web Component, avoiding unnecessary fields.

    Why this is correct

    Selecting only the necessary fields reduces the amount of data transferred from the database to the Apex method and then to the client. Rich text and formula fields can be expensive to compute and transfer. By querying only the fields needed for display, the developer minimizes heap usage and improves response time. This is a best practice for optimizing SOQL queries.

  • ✗

    Use a SOQL query with a LIMIT clause to reduce the number of records returned to 100.

    Why it's wrong here

    Limiting the number of records to 100 would reduce the data returned, but it changes the functionality by not displaying all 500 records. The requirement is to display 500 records, so this is not acceptable. The performance issue is due to selecting unnecessary fields, not the number of records. The developer should optimize the fields instead of reducing the record count.

  • ✗

    Use the @AuraEnabled(cacheable=true) annotation on the Apex method to enable client-side caching.

    Why it's wrong here

    The @AuraEnabled(cacheable=true) annotation enables client-side caching for the Apex method, which can improve performance for repeated calls. However, it does not reduce the initial query cost or the amount of data returned. The developer should first optimize the query to select only needed fields. Caching is beneficial but does not address the root cause of the slow initial load.

  • ✗

    Increase the cacheable scope of the Apex method to 'global' to cache the results across all users.

    Why it's wrong here

    The cacheable scope of an Apex method does not have a 'global' option. The cacheable attribute can be set to true, but the cache level is determined by the platform, not by a scope setting. Also, caching does not reduce the initial query cost; it only helps on subsequent calls. The primary issue is the unnecessary fields being queried.

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.