Skip to main content

query_memory_limit_exceeded

Your analytics query exceeded its memory quota or produced more than 4 MiB of encoded results. Reduce the data processed or returned by the query.
2 min read
Danger
err:user:unprocessable_entity:query_memory_limit_exceeded
Example

What happened?#

Your query exceeded its workspace memory quota or produced an encoded response larger than 4 MiB. Unkey limits both values to prevent one analytics query from exhausting shared resources.

The response limit applies to the encoded JSON size, not only the number of rows. A query can exceed it with one large aggregate value, many projected columns, or many rows.

How to fix it#

1. Return fewer columns and values#

Select only the columns you need. Avoid aggregates such as groupArray that can place an unbounded amount of data into one result value.

2. Use aggregations instead of raw data#

Instead of fetching all rows, aggregate the data:

3. Add more filters#

Reduce the amount of data the query needs to process:

4. Limit result size#

Add a LIMIT to cap the number of returned rows. If the response still exceeds 4 MiB, lower the limit or select fewer columns.

5. Avoid large GROUP BY cardinality#

GROUP BY on high-cardinality columns (like key_id) uses a lot of memory. Instead, group by lower-cardinality columns:

Need a higher memory quota?#

Note

Contact support if your query has a legitimate need for a higher workspace memory quota. The 4 MiB encoded-response limit is fixed, so larger result sets must be split into multiple queries.

Reach out to support and tell us:

  • What you're trying to analyze
  • Why the query needs a higher memory quota
  • An example of the query you're running

Unkey support can review your use case and determine whether a higher workspace memory quota is appropriate.