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?

  • 4
    The data is cached and hence these are separate than your normal salesforce API.Its more like .properties file in Java to me where once an application is started we have some constant data available with us Dec 1, 2013 at 18:44

2 Answers 2


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.

  • 3
    I've never had a problem getting the ID from using the get* methods, but I would definitely suggest querying with FOR UPDATE if you intend to update the record, if only to avoid potential row lock problems.
    – sfdcfox
    Jul 15, 2014 at 5:54

If you use a "SELECT" statement, then they do count towards your query limit. However, since they are in the cache, you can access them through the various cache methods, such as getValues, getOrganizationDefault, etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .