QuestionQ10

VerifiedPerformance Tuning

The data architect at Universal Containers wrote this SOQL query to return all Task records that have no value in the whatID field:

SELECT ID, Description, subject FROM Task WHERE WhatID != NULL  

When the data architect uses this query to select values for a process, it produces a time-out error.

What must the data architect change to make the query more performant?

Explanation

Salesforce cannot use an index to drive a query whose filter uses != or NOT, including a comparison to NULL. Such a predicate can require a full table scan. Filtering on a deterministic, defined value can make the query selective and allow an index to improve performance.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!