#What's the max size for a convex document in terms of the megabytes one document can hold and data?

12 messages · Page 1 of 1 (latest)

tardy stag
#

What's the max size for a convex document in terms of the megabytes one document can hold and data?

acoustic pathBOT
#

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

#

According to the Convex documentation, the maximum size for a single Convex document is 1 MiB (approximately 1.05 MB). This limit applies to the total size of the document, including all its fields and nested data structures.

Specifically, the documentation states:

"Convex values must be less than 1MB in total size." Database > Data Types > Limits (https://docs.convex.dev/database/types#limits)

Additionally, in the production limits section, it's reiterated:

"Size: 1 MiB" Production > State > Limits (https://docs.convex.dev/production/state/limits)

This 1 MiB limit applies to the document as a whole and to any nested objects within it. It's important to note that while a document can contain arrays and nested objects, there are additional constraints:

  1. Documents can have up to 1024 fields.
  2. Arrays can have at most 8192 elements.
  3. The maximum nesting depth for objects and arrays is 16 levels.

These limits ensure efficient data storage and retrieval in the Convex database system. If you find these limits restrictive for your use case, Convex encourages reaching out to their community for support or potential adjustments.

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

#

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

tardy stag
#

What happens if a document more than 1 MB is attempted to be written? Is it possible to cut off at a certain point?

#

@acoustic path What happens if a document more than 1 MB is attempted to be written? Is it possible to cut off at a certain point?

acoustic pathBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

When attempting to write a document larger than 1 MB in Convex, the system will reject the write operation. Convex enforces this limit strictly to maintain performance and efficiency of the database.

According to the documentation:

"Convex values must be less than 1MB in total size." Database > Data Types > Limits (https://docs.convex.dev/database/types#limits)

Unfortunately, there is no built-in mechanism to automatically cut off or truncate documents at the 1 MB limit. The write operation will simply fail if the document exceeds this size.

To handle this situation, you would need to implement your own logic in your application to ensure that documents stay within the 1 MB limit before attempting to write them to the database. This might involve:

  1. Checking the size of the document before writing.
  2. Truncating or compressing data if it's close to or exceeding the limit.
  3. Splitting large documents into smaller, related documents if possible.

If you frequently find yourself needing to store documents larger than 1 MB, you might want to consider alternative strategies, such as storing large data in a separate system and keeping references to it in your Convex documents.

If this limit is particularly challenging for your use case, Convex encourages reaching out to their community. As stated in the documentation:

"If any of these limits don't work for you, let us know (https://convex.dev/community)!" Database > Data Types > Limits (https://docs.convex.dev/database/types#limits)

They may be able to provide additional guidance or consider adjustments to the limits based on user needs.

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

#

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

tardy stag
#

@acoustic path What's the exact size in bytes? The Max

acoustic pathBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

The exact maximum size for a Convex document is 1 MiB (Mebibyte), which is equivalent to 1,048,576 bytes.

This information can be found in the Convex documentation, specifically in the "Production > State > Limits" section, which states:

"Size: 1 MiB" Production > State > Limits (https://docs.convex.dev/production/state/limits)

It's important to note that this 1 MiB (1,048,576 bytes) limit applies to the total size of a single document, including all its fields, nested objects, and arrays. This limit is strictly enforced to ensure efficient data storage and retrieval in the Convex database system.

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