Why are Custom Settings lookups not counted against SOQL Query limits?

Custom setting documentation says “All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database” so does this mean that custom settings are not stored in the database? How does Salesforce exclude custom settings from DB calls?


Custom Settings are persisted in the database. However they’re also cached.

When using the cache methods Custom_setting__c.getAll(), .getInstance(), and .getValues(), Salesforce uses the cached values.

If you use a SOQL query (SELECT id, name, etc FROM Custom_setting__c) to get data for a custom setting, Salesforce queries the database and uses one of your allotted queries.

NOTE: I’ve found that you can only consistently modify a custom setting if you use a SOQL query to load it. Loading via a cache method does not load the custom setting’s id which is required to update the custom setting.

Source : Link , Question Author : Shebin Mathew , Answer Author : Matt Lacey

Leave a Comment