Loading

Record size calculation for Custom Settings

Fecha de publicación: Aug 28, 2023
Descripción
The total amount of cached data allowed for Salesforce org for custom settings is the lesser of these two values:
  • 20 MB
  • 2 MB multiplied by the number of provisioned full-featured Salesforce user licenses
 
Solución
For example, if the org has three full licenses, it has 6 MB of custom setting storage. If the org has 20 full licenses, it have 20 MB of storage.

Each certified managed package gets a separate limit in addition to your org limit. For example, let’s say the org has two certified managed packages installed and has three full licenses. Each certified managed package can have 6 MB of custom setting storage in addition to the Org’s 6 MB custom setting storage limit.

Custom settings are cached in a special application layer cache which allows a developer to access this data without performing a query, similar to how a CPU's cache allows it to access frequently accessed information without requesting the data from main system memory.

All custom settings are cached, and each record in the cache counts towards the 10MB/1MB-per-user limit. These records are charged based on the size of the data contained in each row. This is shown in the custom settings "record size" attribute. The more fields you have, and the larger they are, the more data is required per row.

Let's say that you have just one user license, and therefore limited to 2MB of cached data. This is equal to 1,048,576 bytes of data-- the extra 48,576 bytes comes from the traditional method of counting memory, where a kilobyte is 1,024 bytes, and a megabyte is 1,024 kilobytes. If each row is 384 bytes, you could store 2,730 rows of data (the remaining data is not usable for this custom setting). Conversely, if your record size is 3,112 bytes, your 1MB limit would result in just 336 rows of data available.

The record size attribute tells you how large each row is, and the total size attribute is simply the record size times the number of rows stored. For this reason, since every byte matters, it is important that you allocate only enough size to each field to store the required data. For example, if you are storing relational ID values, make sure the field is only 18 characters long, and not 255 characters long (resulting in a waste of 1,317% of the required space). Similarly, store a number in a number field, not a text field, since numbers require less memory to store (a full 18 digit number stores in about 8 bytes of data, instead of 18 bytes of text).

There is also additional overhead per field, so keep this in mind as well; using more custom settings with fewer fields will generally yield less cache usage than a few custom settings with many fields.

Custom settings should only contain data that needs to be protected or tucked away from regular users. There are no "sharing settings" on these records, and they are only accessible by code when they are protected in a managed package. This makes them ideal for storing passwords, security tokens, encryption keys, etc, that users shouldn't have easy access to. Even unprotected custom settings are acceptable for storing small amounts of data that needs to be accessed frequently, such as user preferences and configuration settings.
Número del artículo de conocimiento

000383546

 
Cargando
Salesforce Help | Article