Development questions

How do you query Custom Metadata Types (getAll(), getInstance()) without consuming SOQL governor limits?

DevelopmentMediumAccentureInfosysCapgemini

Custom metadata type records can be read with Apex methods that do not count against SOQL limits:

apex
Map<String, My_Setting__mdt> all = My_Setting__mdt.getAll();   // all records, keyed by DeveloperName
My_Setting__mdt one = My_Setting__mdt.getInstance('Default');   // by DeveloperName or Id

getAll()/getInstance() return cached records but not all long-text fields. Querying with SOQL still works (and counts toward limits) when you need filters or those fields.

soqlcustom-metadatagovernor-limits