bonsaidb_core/
limits.rs

1//! Limits used within BonsaiDb.
2//!
3//! Unless otherwise noted, all size limits will be affected by compression, if
4//! enabled.
5//!
6//! # Transaction Limits
7//!
8//! The serialized summary of [`Changes`](crate::transaction::Changes) of a
9//! transaction must be less than 16 megabytes. This limit comes from
10//! [Nebari][nebari]'s transaction log entry size limit.
11//!
12//! When querying previously executed transactions using
13//! [`Connection::list_executed_transactions()`](crate::connection::Connection::list_executed_transactions),
14//! the result set will be limited to [`LIST_TRANSACTIONS_MAX_RESULTS`] entries.
15//!
16//! # Document Limits
17//!
18//! ## Primary Key Limits
19//!
20//! [`DocumentId::MAX_LENGTH`](crate::document::DocumentId::MAX_LENGTH) is the
21//! maximum number of bytes a document ID can contain when in its serialized
22//! form. This is currently 64 kilobytes of data.
23//!
24//! ## Size Limits
25//!
26//! Each document can be up to 4 gigabytes in size (4,294,967,296 bytes).
27//! However, care should be used when storing large documents, as the only way
28//! to load a document is for its entire data to be read from disk into memory.
29//! Storing large documents can lead to higher memory usage than you might
30//! anticipate.
31//!
32//! Many NoSQL databases enforce document size limits at 16 megabytes or
33//! smaller, which encourages usage patterns that require less RAM. While
34//! BonsaiDb doesn't have as restrictive of a limit, users should consider
35//! approaches that keep document sizes smaller if RAM is a constraint.
36//!
37//! # View Limits
38//!
39//! The serialized representation of the `Key` type must be less than 64
40//! kilobytes (65,536 bytes). It should be noted that using large keys will slow
41//! the view's performance. This is one reason why document IDs enforce a
42//! smaller size limit. By not enforcing as restrictive of a limit on views,
43//! more complex indexes can be built such as allowing tuples of strings of
44//! arbitrary length.
45//!
46//! The serialized representation of all mappings emitted for a single `Key`
47//! must be less than 4 gigabytes in size.
48//!
49//! [nebari]: https://github.com/khonsulabs/nebari
50
51/// The maximum number of results allowed to be returned from `list_executed_transactions`.
52pub const LIST_TRANSACTIONS_MAX_RESULTS: u32 = 1000;
53/// If no `result_limit` is specified, this value is the limit used by default.
54pub const LIST_TRANSACTIONS_DEFAULT_RESULT_COUNT: u32 = 100;