#Limits for queries by ctx.runQuery

4 messages · Page 1 of 1 (latest)

fast fossil
#

when i use ctx.runQuery, do the row scanning limits apply once or once per sub-query?

onyx viperBOT
#

Hi @fast fossil. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

When you use ctx.runQuery in an action, each call to ctx.runQuery executes a separate query function, and the row scanning (document scan) limits apply to each individual query function execution, not to the action as a whole. This means that if you call ctx.runQuery multiple times within an action, each query is subject to the document scan and data read limits independently.

For example, the limits for a single query function are:

If you call ctx.runQuery twice, each call can scan up to the limit, but they are not combined into a single limit for the action. However, keep in mind that running multiple ctx.runQuery calls in sequence means each runs in its own transaction, and you lose consistency guarantees between them. This is why it's recommended to batch your logic into a single query or mutation when possible Best Practices.

In summary: the row scanning limits apply per query function execution, i.e., per ctx.runQuery call, not per action as a whole.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@fast fossil Kapa.ai is still learning and improving, please let me know how I did by reacting below.