# Large sets

Repeatable fields in ACF are stored as data arrays in Metafields of type  "json\_string" which in Shopify has a storage limit of 100,000 characters.\
\
This limit may prove a challenge when working with large sets of repeatable fields, especially of types Media v2 or HTML in excess of 100-150 occurrences (sometimes fewer when working with large blocks of HTML).\
\
ACF is able to work around this limitation by distributing your content across multiple individual Metafields. This is something you need to enable on a per-field basis (due to the theme handling being different - see below) but is otherwise handled internally to give you a seamless experience when working in the ACF editor or with exports/imports.

![](https://3940270179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbIlmOfNwpXqPZMStJkgh%2Fuploads%2FP0ziRDDs4bjkpLH7aRnY%2FCleanShot%202021-11-08%20at%2014.15.03%402x.png?alt=media\&token=c9613d2a-549d-429d-98ba-fefde8a547cc)

The "automatically handle large sets of repeatable values" setting is available for all field types that can be defined as repeatable (with the exception of Shopify » ... types, see below) and for all scopes except for product types, vendors, and locations.\
\
With "large sets" enabled the storage limit is now 1,000,000 characters, which allows you to work with sets in excess of 1,000 elements.

{% hint style="info" %}
Note that each individual occurrence (e.g a block of HTML) still needs to fit inside 100,000 characters Metafield and - in case of 10+ occurrences - this space is shared with other occurrences\
\
A rough calculation of the size limit per occurrence (for reasonably like-sized blocks) is 100,000 / ceil(#occurrences / 10)
{% endhint %}

{% hint style="warning" %}
Large sets are not available for Shopify » ... types
{% endhint %}

### Required theme changes

So why is this just not enabled by default? The reasoning here is that enabling the setting requires a subtle change to your theme since the original Metafield no longer contains the actual data items but rather is a "reference object" with references to the actual data Metafields.

#### Example code - looping HTML blocks

This code example shows you how to loop a repeatable HTML field with "large sets" enabled:

```liquid
{% for html in shop.metafields.globals.very_large_description %}
  {{ shop.metafields.globals[html.metafield][html.index] }}
{% endfor %}
```

Please note that the code doesn't just render the "html" loop variable as we would for a traditional repeatable field but uses it as a reference to get to the actual Metafield used to store the data for that specific entry.\
\
\&#xNAN;*shop.metafields.globals* should be replaced with whatever scope and namespace your field is defined under, for example, *product.metafields.accentuate*.

#### Example code - looping Media v2 fields

This code example shows you how to loop a repeatable Media v2 field with "large sets" enabled:

```liquid
{% for media in shop.metafields.globals.very_large_media_set %}
  {% assign single_media = shop.metafields.globals[media.metafield][media.index] | first %}
  <img src="{{ single_media.src }}" alt="{{ single_media.alt }}"/>
{% endfor %}
```
