[SalesForce] the performance difference between custom metadata types and record based configuration

It is my understanding that custom metadata types are more efficient than record based configuration because you do not have to hit the database to retrieve their information. Is this correct? Are there other performance advantages to using custom metadata types as opposed to record based configuration?

Best Answer

There are performance gains with custom metadata as custom metadata is cached after first read.

From the salesforce docs

Custom metadata records are cached at the type level after the first read request. Caching enhances performance on subsequent requests. Requests that are in flight when metadata is updated don’t get the most recent metadata.

Also the other advantages include below

  1. Ability to associate relation between objects (Using Entity relationships)
  2. Ability to protect secret using protected custom metadata
  3. Easy deployment as a metadata between sandboxes and production and ability to package them for ISV apps
  4. SOQL executed does not count against the 100 SOQL limit we have per execution

Note: Object entity and field definition fields are slow to load when used in custom metadata types and their records in SQOL. Check here (How to improve performance when querying CustomMetadata's FieldDefinition fields)