Each query hitting our Content Delivery API has a complexity cost based on
which type of field is present
how many fields are present
how many filters are present
how many sorting parameters are present
the page size
Each DatoCMS plan comes with a maximum allowed complexity cost which is 10,000,000 by default. Take a look at the "Plan and usage" section of your project in the Account dashboard to understand which is your complexity limit.
The Content Delivery API sets the X-Complexity
header in the response to let you know the calculated complexity cost for your submitted query and the X-Max-Complexity
header containing your current plan complexity limit.
If the query complexity cost above your plan limit you'll get an error from the Content Delivery API:
Unless specified otherwise, each requested GraphQL field has a cost of 1.
Each filter argument has a cost of 250, except for deep filtering arguments.
Each sorting parameter has a cost of 250.
To calculate the pagination cost, multiply the page size by the inner fields' cost. By default, the page size is 20 but you can override it using the first
argument.
Root fields like allArtists
have a base cost of 100. To this, the cost of filters, the cost of sorting, and the cost of pagination must be added.
The following query has a cost of 140: 100 (base) + 20 (implicit page size) x 2 (inner fields' cost)
query { # it returns at max 20 records by default allArtists { # 100 id # 1 name # 1 }}
The following query has a cost of 1,175: 100 (base) + 750 (filtering) + 250 (sorting) + 25 (page size) x 3 (inner fields' cost)
1query {2 allArtists( # 1003 filter: {4 birth: {gt: "1990-01-01", lt: "2010-01-01"}, # 250 x 2 => 5005 country: {eq: "DE"} # 2506 },7 orderBy: [name_ASC], # 2508 first: 25 # explicit page size9 ) {10 id # 111 name # 112 age # 113 }14}
Root fields like _allArtistsMeta
have a base cost of 1,000. To this, the cost of filters and the inner field's cost must be added.
The following query has a cost of 1,251: 1,000 (base) + 250 (filtering) + 1 (inner fields' cost)
query { _allArtistsMeta( # 1,000 filter: { country: {eq: "NL"} } # 250 ) { count # 1 }}
Root fields like artist
have a base cost of 50. To this, the cost of filters, the cost of sorting, and the inner fields' cost must be added.
The following query has a complexity cost of 301: 50 (base) + 250 (filtering) + 1 (inner fields' cost)
query { artist( # 50 filter: { id: {eq: "123"} } # 250 ) { name # 1 }}
Root fields about single-instance records have a base cost of 25. To this, the inner field's cost must be added.
The following query has a cost of 27: 25 (base) + 2 (inner fields' cost)
query { contactPage { # 25 phoneNumber # 1 emailAddress # 1 }}
Fields like _allReferencingMovies
can be used once activated the inverse relationships feature for the model. They have a base cost of 100. To this, the cost of filters, the cost of sorting, and the cost of pagination must be added.
The following section has a cost of 1,110: 100 (base) + 500 (filtering) + 500 (sorting) + 5 (page size) x 2 (inner fields' cost)
1...2 _allReferencingMovies( # 1003 through: {4 fields: {anyIn: [movie_artist]}, # 2505 locales: {anyIn: en} # 2506 },7 orderBy: [title_ASC, _createdAt_DESC], # 500,8 first: 5 # explicit page size9 ) {10 id # 111 title # 112 }13...
Fields like _allReferencingMoviesMeta
have a base cost of 1,000. To this, the cost of filters and the inner fields' cost must be added.
The following section has a cost of 1,001.
... _allReferencingMoviesMeta { # 1,000 count # 1 }...
The following GraphQL fields differ from the base cost (1):
Single asset field: 5
Asset gallery field: 5 x inner fields' cost
Multiple-paragraph text, when rendering Markdown in HTML: 5
JSON field: 5
Single link field: 10
Multiple links field: 5 x inner fields' cost
Modular content field: 5 x inner fields' cost
Structured text field
value: 10
blocks: 5 x inner fields' cost
links: 5 x inner fields' cost
children
field (available in tree collections): 5 x inner fields' cost
parent
field (available in tree collections): 25
Localized field
value: number of environment's locales x inner fields' cost
SEO field
image: 5
_seoMetaTags
: 5
The following query has a cost of 351, composed by:
50 (base cost of single record field)
250 (filtering)
5 + 1 + 5 (photo field)
10 + 5 x 1 + 5 x 2 (content field)
5 x 3 (movies field)
1query {2 artist( # 503 filter: { id: {eq: "123"} } # 2504 ) {5 photo { #single asset field: 56 url # 17 blurUpThumb # 58 }9 content { # structured text field10 value # 1011 links { # 5 x inner fields' cost12 id # 113 }14 blocks { # 5 x inner fields' cost15 id # 116 text # 117 }18 }19 movies { # multiple links field: 5 x inner fields' cost20 id # 121 title # 122 releaseDate # 123 }24 }
A GraphQL union complexity is the max complexity between all of the possible types.
The modular content field content
has a complexity cost of 10: 5 x 2
1query {2 artist(filter: { id: { eq: "123" }}) {3 name4 content { # 5 x max possible union's cost5 ... on MovieRecord {6 title # 17 }8 ... on TvSerieRecord {9 title # 110 channel # 111 }12 }13 }14}
Normally, each filter argument has a cost of 250, but when using deep filtering an additional cost of 1,000,000 is added for each type of block model defined in the filter.
The following query has a cost of 2,000,890: 100 (base) + 2,000,750 (filtering) + 20 (implicit page size) x 2 (inner fields' cost)
1query {2 allBlogPosts( # 1003 filter: {4 content: {5 any: {6 product: { # 1,000,0007 name: {8 eq: "T-Shirt" # 2509 },10 price: {11 gt: 30 # 25012 }13 }14 cta: { # 1,000,00015 title: {16 isPresent: true # 25017 }18 }19 }20 }21 }22 ) {23 id # 124 title # 125 }26}
Root field allUploads
has a base cost of 100. To this, the cost of filters, the cost of sorting, and the cost of pagination must be added.
The following query has a cost of 801: 100 (base) + 250 (filtering) + 250 (sorting) + 30 (page size) x 7 (inner fields' cost)
1query {2 allUploads( # 1003 filter: {format: {eq: "jpg"}}, # 2504 orderBy: [size_DESC], # 2505 first: 30 # explicit page size6 ) {7 id # 18 url # 19 blurUpThumb # 510 }11}
Root field _allUploadsMeta
has a base cost of 1,000. To this, the cost of filters and the inner fields' cost must be added.
The following query has a cost of 1,251: 1,000 (base) + 250 (filtering) + 1 (inner fields' cost)
query { _allUploadsMeta( # 1,000 filter: {format: {eq: "jpg"}} # 250 ) { count # 1 }}
Root field upload
has a base cost of 50. To this, the cost of filters, the cost of sorting, and the inner fields' cost must be added.
The following query has a complexity cost of 308: 50 (base) + 250 (filtering) + 8 (inner fields' cost)
1query {2 upload( # 503 filter: {id: {eq: "123"}} # 2504 ) {5 url #16 title #17 blurUpThumb # 58 blurhash #19 }10}
The following GraphQL fields differ from the base cost (1):
blurUpThumb: 5
Root field _site
has a base cost of 10. To this, the inner fields' cost must be added.
The following query has a cost of 13.
query { _site { # 10 globalSeo { # 1 siteName # 1 titleSuffix # 1 } }}