Courseiva
Performance →hardMultiple Choice

SF-PD2 Performance Practice Question

A developer is designing a solution to calculate real-time statistics on a high-volume custom object, `Sensor_Reading__c`, which receives thousands of new records per hour. The statistics must be displayed on a Lightning Web Component (LWC) dashboard and must reflect the most recent data within 5 minutes. The developer considers using a scheduled Apex job to aggregate data every 5 minutes, but the aggregation query takes longer than 5 minutes to run. What is the most appropriate approach to meet the performance requirement?

⚠ Common exam trap

The trap here is assuming that scheduled aggregation or batch processing can meet near real-time requirements, when the underlying query is too slow. Incremental processing via CDC is the key.

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

✓

Implement a Change Data Capture (CDC) event subscriber that updates a custom summary object in real time as new Sensor_Reading__c records are inserted.

Change Data Capture (CDC) allows real-time streaming of record changes. By subscribing to CDC events for `Sensor_Reading__c`, the developer can incrementally update a summary object as each new reading is inserted, avoiding the need for a long-running aggregation query. This meets the 5-minute freshness requirement and scales with high volume. Other options either rely on slow batch processing or incorrect use of formula 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.

  • ✗

    Create a formula field on Sensor_Reading__c that calculates the statistics dynamically and reference it in the LWC.

    Why it's wrong here

    Formula fields cannot aggregate data across multiple records; they operate on a single record. They cannot calculate statistics like sums or averages across thousands of records. This option is technically impossible for the requirement and would not provide the needed aggregated statistics.

  • ✓

    Implement a Change Data Capture (CDC) event subscriber that updates a custom summary object in real time as new Sensor_Reading__c records are inserted.

    Why this is correct

    Change Data Capture publishes events when records change, allowing a subscriber to process each new record and update a summary object incrementally. This avoids running a heavy aggregation query and keeps statistics up-to-date in near real-time, well within the 5-minute window. It is scalable and efficient for high-volume data.

  • ✗

    Use a Platform Cache to store the aggregated statistics and refresh it asynchronously using a Queueable job triggered by a record-triggered flow.

    Why it's wrong here

    While Platform Cache can store statistics, refreshing it asynchronously via a Queueable job triggered by a record-triggered flow may not meet the 5-minute freshness requirement if the aggregation itself takes longer than 5 minutes. The bottleneck is the aggregation query, not the storage. This approach does not solve the core performance issue.

  • ✗

    Use a Batch Apex job with a scope size of 1 to process each new record individually and update the summary object.

    Why it's wrong here

    Batch Apex with a scope size of 1 processes records one at a time, which is inefficient for high-volume data and may not complete within 5 minutes. It also runs asynchronously and may have delays. This approach is not suitable for real-time statistics and would likely exacerbate performance issues.

About these practice questions

One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.