Praxis Academy
Home › Platform Developer II › Performance

Platform Developer II practice questions: Performance

Performance is 18% of the Salesforce Certified Platform Developer II exam. It covers selective SOQL, large data volumes, Platform Cache and efficient UI. Try these 14 free questions, then open each answer to see why every option is right or wrong.

01

A logistics company stores 2,500,000 Shipment__c records. A report-driven Apex query filters only on CreatedDate, a standard indexed field. What is the maximum number of records the filter can return and still be considered selective by the Force.com query optimizer?

  1. 100,000
  2. 175,000
  3. 525,000
  4. 1,000,000
Show answer

Answer: C

A. 100,000This is 10% of the first million, which relates to the custom index threshold, and it ignores the remaining records.
B. 175,000This is the custom index threshold (10% of the first million plus 5% of the rest), not the standard index threshold.
C. 525,000 ✓Correct. A standard index is selective up to 30% of the first 1 million records plus 15% of the remaining 1.5 million: 300,000 + 225,000.
D. 1,000,000One million is the absolute cap for standard index thresholds, but this object's calculated threshold is lower.

Why: Standard index selectivity is 30% of the first million records plus 15% of records beyond that, capped at 1 million. Custom indexes use 10% and 5%, capped at 333,333.

02

A manufacturer searches 2 million Serial__c records with WHERE Code__c LIKE '%-MX24'. Code__c is an External ID field, yet the query times out. What is the most effective fix?

  1. Change the filter to LIKE '%MX24%' to widen the match
  2. Ask Salesforce Customer Support to create a skinny table on Serial__c
  3. Convert Code__c into a Long Text Area field
  4. Store the suffix in a separate indexed field and filter it with equality
Show answer

Answer: D

A. Change the filter to LIKE '%MX24%' to widen the matchA leading wildcard is still present, so the index still cannot be used and more rows match.
B. Ask Salesforce Customer Support to create a skinny table on Serial__cA skinny table reduces joins, but a leading-wildcard filter still forces a scan of all rows.
C. Convert Code__c into a Long Text Area fieldLong Text Area fields cannot be filtered in SOQL WHERE clauses at all.
D. Store the suffix in a separate indexed field and filter it with equality ✓Correct. Leading wildcards prevent index use; a dedicated indexed field with an equality filter can be selective.

Why: LIKE filters with a leading wildcard cannot use an index. Denormalizing the searchable part into its own indexed field restores selectivity.

03

A retailer queries 3 million Customer__c records with WHERE Email__c = :email OR Phone__c = :phone. Email__c is an External ID; Phone__c has no index. The query is slow. Why?

  1. OR filters can never use indexes in SOQL
  2. For an OR filter to use indexes, every condition must be indexed and selective
  3. External ID fields are not indexed for equality comparisons
  4. Bind variables disable index usage in SOQL
Show answer

Answer: B

A. OR filters can never use indexes in SOQLOR filters can use indexes when every condition is on an indexed field and each is selective.
B. For an OR filter to use indexes, every condition must be indexed and selective ✓Correct. Because Phone__c is not indexed, the optimizer cannot use an index for the OR and falls back to a scan.
C. External ID fields are not indexed for equality comparisonsExternal ID fields are automatically indexed and support equality filtering.
D. Bind variables disable index usage in SOQLBind variables are evaluated as literal values and do not prevent index usage.

Why: With OR, the optimizer needs an index on each branch and each branch must be selective; one unindexed branch forces a full scan.

04

A bank is migrating 8 million accounts and will also reassign thousands of users to new roles and public groups during the same weekend. Which approach minimizes total processing time for sharing?

  1. Run the user reassignments first, then load the records in serial mode
  2. Enable Defer Sharing Calculations, make the changes and loads, then resume and recalculate once
  3. Set all objects to Public Read/Write and change them back after go-live
  4. Create Apex managed sharing for all accounts after loading
Show answer

Answer: B

A. Run the user reassignments first, then load the records in serial modeEach role and group change still triggers immediate recalculation, which is slow at this volume.
B. Enable Defer Sharing Calculations, make the changes and loads, then resume and recalculate once ✓Correct. Deferring sharing calculations lets many changes be applied before a single recalculation.
C. Set all objects to Public Read/Write and change them back after go-liveChanging OWDs back triggers a full recalculation and exposes data during the migration.
D. Create Apex managed sharing for all accounts after loadingThis adds millions of share rows and does not avoid recalculation from role and group changes.

Why: The Defer Sharing Calculations permission (enabled by Salesforce Customer Support) suspends group membership and sharing rule calculations so they run once after bulk changes.

05

A before-insert trigger on Opportunity contains: for (Opportunity o : Trigger.new) { Account a = [SELECT Tier__c FROM Account WHERE Id = :o.AccountId]; o.Tier__c = a.Tier__c; } A data load of 500 opportunities fails. What is the best fix?

  1. Change the trigger to after insert and update the records with DML
  2. Collect AccountIds in a Set, run one query into a Map<Id, Account>, then read from the Map in the loop
  3. Add LIMIT 1 to the query inside the loop
  4. Wrap the query in a try/catch block to skip failures
Show answer

Answer: B

A. Change the trigger to after insert and update the records with DMLAfter-insert updates add DML and recursion risk, and the query is still inside the loop.
B. Collect AccountIds in a Set, run one query into a Map<Id, Account>, then read from the Map in the loop ✓Correct. One bulkified query avoids the 100-query synchronous limit regardless of batch size.
C. Add LIMIT 1 to the query inside the loopLIMIT 1 does not reduce the number of queries, so the 101st iteration still fails.
D. Wrap the query in a try/catch block to skip failuresA LimitException cannot be caught, so the transaction still fails.

Why: Queries inside loops quickly exceed the 100 SOQL query limit. Bulkify by gathering keys first and querying once into a Map.

06

A Batch Apex job must send each Lead__c record to an address-validation API with one callout per record. The first test run fails with 'Too many callouts: 101'. What should the developer do?

  1. Move the callouts into the finish method
  2. Wrap each callout in a try/catch and continue
  3. Implement Database.AllowsCallouts and call Database.executeBatch(job, 100) or a smaller scope
  4. Use a future method with callout=true inside execute
Show answer

Answer: C

A. Move the callouts into the finish methodThe finish method runs once in its own transaction and is also limited to 100 callouts.
B. Wrap each callout in a try/catch and continueA limit exception cannot be caught, and the job still exceeds the callout limit.
C. Implement Database.AllowsCallouts and call Database.executeBatch(job, 100) or a smaller scope ✓Correct. Each execute call is a separate transaction limited to 100 callouts, so the scope must not exceed that.
D. Use a future method with callout=true inside executeFuture methods cannot be called from Batch Apex.

Why: Each execute invocation is its own transaction with a 100-callout limit. Callouts in Batch Apex require Database.AllowsCallouts, and the scope size should match the callout needs.

07

A Lightning web component calls an Apex method that waits on a legacy pricing service taking 30-60 seconds. During peak hours, users get errors because too many long-running requests run at once. Which solution best addresses this?

  1. Increase the HttpRequest timeout to 120 seconds
  2. Call the service from a @future method and poll for the result every second
  3. Use an Apex Continuation to make the callout asynchronously
  4. Mark the Apex method @AuraEnabled(cacheable=true)
Show answer

Answer: C

A. Increase the HttpRequest timeout to 120 secondsA longer timeout keeps the request synchronous and makes the concurrency problem worse.
B. Call the service from a @future method and poll for the result every secondAggressive polling adds server requests and does not return the result to the component cleanly.
C. Use an Apex Continuation to make the callout asynchronously ✓Correct. Continuations free the server thread while waiting, so they do not count toward the concurrent long-running request limit.
D. Mark the Apex method @AuraEnabled(cacheable=true)Caching helps only for repeated identical requests and does not shorten the initial wait.

Why: Apex Continuations let Visualforce, Aura and Lightning web components make long-running callouts without holding a server thread, avoiding the concurrent long-running request limit.

08

A team is designing a caching strategy for a customer portal. Which statements about Platform Cache are accurate? (Choose 2)

  1. Values can be evicted before their time-to-live expires
  2. Session cache values can be shared between different users
  3. Org cache values are available to all users and requests in the org
  4. Cache.Org.put() calls count toward the DML statement limit
  5. Cached values are copied to sandboxes when they are refreshed
Show answer

Answer: A, C

A. Values can be evicted before their time-to-live expires ✓Correct. When a partition reaches capacity, less recently used values can be evicted early.
B. Session cache values can be shared between different usersSession cache is tied to a single user session and is not shared between users.
C. Org cache values are available to all users and requests in the org ✓Correct. Org cache stores data that any user or request in the org can access.
D. Cache.Org.put() calls count toward the DML statement limitCache operations are not DML and do not count toward the DML statement limit.
E. Cached values are copied to sandboxes when they are refreshedCache contents are transient and are not copied during a sandbox refresh.

Why: Platform Cache offers Org and Session partitions. Org cache is shared across the org; Session cache is per user session. Neither guarantees that data stays until its TTL.

09

A Visualforce dashboard page for executives queries 300,000 Activity__c rows to compute counts and never performs DML. It fails with 'Too many query rows: 50001'. Which change addresses the limit with minimal code change?

  1. Annotate the controller class with without sharing
  2. Set readOnly="true" on the apex:page tag
  3. Move the query into the page's action attribute
  4. Add the transient keyword to the result list
Show answer

Answer: B

A. Annotate the controller class with without sharingSharing keywords change visibility, not the query row limit.
B. Set readOnly="true" on the apex:page tag ✓Correct. Read-only mode raises the query row limit to 1 million rows and the collection iteration limit to 10,000, but disallows DML.
C. Move the query into the page's action attributeThe action method runs in the same request with the same 50,000-row limit.
D. Add the transient keyword to the result listTransient reduces view state but does not change the query row limit.

Why: Visualforce read-only mode (readOnly="true") relaxes the query row limit to 1,000,000 rows for pages that only display data.

10

A Lightning web component shows open tasks via @wire(getOpenTasks, { accountId: '$recordId' }) wiredTasks. After the user closes a task through an imperative Apex call, the list still shows the old task. What should the developer do?

  1. Call refreshApex(this.wiredTasks) after the imperative update completes
  2. Remove cacheable=true from getOpenTasks
  3. Reload the page with window.location.reload()
  4. Change recordId to a different value and then back
Show answer

Answer: A

A. Call refreshApex(this.wiredTasks) after the imperative update completes ✓Correct. refreshApex re-provisions the wired result from the server and updates the cached value.
B. Remove cacheable=true from getOpenTasks@wire requires cacheable methods, so removing it breaks the wire adapter.
C. Reload the page with window.location.reload()A full reload is slow and discards the benefit of client caching.
D. Change recordId to a different value and then backManipulating parameters to force a refresh is a fragile workaround, not the supported pattern.

Why: When data changes outside Lightning Data Service, refreshApex() refreshes the value of a wired Apex method.

11

A Lightning web component polls an Apex method every five seconds to check whether a long-running import job has finished. Hundreds of users keep the page open, generating heavy server traffic. Which design is more efficient?

  1. Reduce the polling interval to every 30 seconds
  2. Publish a platform event when the job finishes and subscribe in the component with lightning/empApi
  3. Mark the polling Apex method cacheable=true
  4. Move the polling logic into a Visualforce page with actionPoller
Show answer

Answer: B

A. Reduce the polling interval to every 30 secondsLess frequent polling reduces load but still makes many unnecessary calls and delays the update.
B. Publish a platform event when the job finishes and subscribe in the component with lightning/empApi ✓Correct. Event-driven notification pushes the update once, replacing constant polling.
C. Mark the polling Apex method cacheable=trueCached responses would hide the status change, defeating the purpose of polling.
D. Move the polling logic into a Visualforce page with actionPolleractionPoller is still polling and has the same load problem.

Why: Streaming with platform events (via lightning/empApi) lets components react to server-side changes without polling.

12

A trigger matches 10,000 incoming Contacts to 10,000 Accounts using nested for loops over both lists and exceeds the CPU time limit during data loads. Which changes reduce CPU consumption? (Choose 2)

  1. Build a Map keyed by the matching value and look up each Contact in the Map
  2. Add System.debug statements inside the loops to track progress
  3. Wrap the loops in a try/catch block
  4. Change the trigger from before insert to after insert
  5. Move non-urgent follow-up processing into a Queueable job
Show answer

Answer: A, E

A. Build a Map keyed by the matching value and look up each Contact in the Map ✓Correct. Map lookups replace O(n x m) nested iteration with near-constant-time access.
B. Add System.debug statements inside the loops to track progressDebug statements consume CPU time, especially in loops with high log levels.
C. Wrap the loops in a try/catch blockException handling does not reduce the work performed inside the loops.
D. Change the trigger from before insert to after insertThe timing of the trigger does not change the cost of the nested loops.
E. Move non-urgent follow-up processing into a Queueable job ✓Correct. Asynchronous work runs in a separate transaction with its own (higher) CPU limit, reducing the load on the synchronous trigger.

Why: CPU time is consumed by Apex code execution. Efficient data structures and offloading non-critical work to async processing are the main remedies.

13

An order-processing class publishes an Error_Log__e platform event inside a try/catch before rethrowing, so failures are recorded. The team finds that no logs appear when the transaction rolls back. What should the developer change?

  1. Set the platform event's Publish Behavior to Publish Immediately
  2. Set the platform event's Publish Behavior to Publish After Commit
  3. Insert a Log__c record in the catch block instead
  4. Publish the event from a @future method
Show answer

Answer: A

A. Set the platform event's Publish Behavior to Publish Immediately ✓Correct. Publish Immediately sends the event regardless of whether the transaction commits, so logs survive rollbacks.
B. Set the platform event's Publish Behavior to Publish After CommitPublish After Commit sends the event only if the transaction succeeds, which is the current problem.
C. Insert a Log__c record in the catch block insteadRegular DML is rolled back along with the rest of the failed transaction.
D. Publish the event from a @future methodThe future call is also discarded when the enqueuing transaction rolls back.

Why: Platform events configured to Publish Immediately are delivered even if the publishing transaction fails, which makes them suitable for error logging.

14

A collections team filters 5 million Invoice__c records on Days_Overdue__c, a formula defined as TODAY() - Due_Date__c. Queries are slow, and the admin asks Salesforce Customer Support for a custom index on the formula. What is the best response?

  1. The formula cannot be indexed because it is non-deterministic; filter on an indexed Due_Date__c range instead
  2. Support can index it as long as the formula returns a Number
  3. Mark the formula field as an External ID
  4. Convert the formula to a roll-up summary on the parent Account
Show answer

Answer: A

A. The formula cannot be indexed because it is non-deterministic; filter on an indexed Due_Date__c range instead ✓Correct. Formulas that use TODAY() or similar functions cannot be indexed; an equivalent date-range filter on Due_Date__c can be.
B. Support can index it as long as the formula returns a NumberThe return type does not matter; the use of TODAY() makes it non-deterministic.
C. Mark the formula field as an External IDFormula fields cannot be marked as External ID.
D. Convert the formula to a roll-up summary on the parent AccountA roll-up summary changes the data model and does not support filtering invoices by days overdue.

Why: Only deterministic formula fields can receive custom indexes. Rewriting filters against indexed source fields, such as a date range, keeps queries selective.

Find out if you're ready to pass

Take the free Platform Developer II diagnostic: 20 questions, no account needed. Then unlock all 300 questions, full practice exams and the study guide.

Start the free diagnosticSee plans

Other sections of this exam