🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Do sub queries inside GROQ count as individual queries towards the plan quota?

2 replies
Last updated: Apr 9, 2024
Hey hey! Super simple question, if you know the answer. 😁
Do sub queries inside GROQ count as individual queries towards the plan quota, or do they not count?
Apr 8, 2024, 9:17 PM
No, they don’t count extra. The following all count as one query:

*[_type == 'author']

*[_type == 'author']{
  ...,
  'posts': *[_type == 'post' && author._ref == ^._id],
}

{
  'authors': *[_type == 'author'],
  'posts': *[_type == 'post'],
}
Things you will want to consider are (1) query complexity and speed and (2) the
bandwidth of each query, which (very probably) does increase in queries 2 and 3 (compared to 1).
Apr 8, 2024, 9:32 PM
Thanks!
Apr 9, 2024, 5:15 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?