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

**Topic:** Soql · **Difficulty:** Medium · **Asked at:** Accenture, Infosys, Capgemini · **Tags:** soql, custom-metadata, governor-limits

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-you-query-custom-metadata-types-getall-getinstance-without-consuming-soql-governor-limits

## Answer

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.

---
Source: ForceChallenges · last updated 2026-10-21
