Skip to content

Limitations

slate wraps Erlang's DETS, which has several inherent limitations. Understanding these helps you choose the right storage approach.

DETS tables are limited to 2 GB per file. This is a hard limit in the DETS implementation and cannot be configured. If a table exceeds this size, operations will return Error(FileSizeLimitExceeded).

Unlike Erlang's ETS (in-memory storage), DETS does not support ordered_set tables. Only set, bag, and duplicate_bag are available. Keys are stored in an unspecified order.

DETS performs disk I/O on every read and write. This makes it unsuitable for high-frequency operations where latency matters. For performance-critical reads, consider loading data into ETS at startup and using DETS only for persistence.

If a DETS table is not closed properly (for example, because the owning process exits unexpectedly), pending writes may be lost and the file may need repair on the next open. Use with_table for short-lived operations that should clean up when the callback returns or raises, or call close yourself for longer-lived tables.

By default, slate uses AutoRepair, which automatically repairs improperly closed tables. You can also use ForceRepair to always repair, or NoRepair to return an error instead.

DETS is a BEAM feature. slate only works with Gleam's Erlang target — there is no JavaScript target support.

slate uses a bounded internal pool of DETS table names instead of creating one atom per path. That avoids unbounded atom growth, but it also means only a bounded number of distinct tables can be open at once. If you open too many different paths concurrently, new opens can fail until some tables are closed.

No concurrent access from multiple OS processes

Section titled “No concurrent access from multiple OS processes”

A DETS file should only be opened by a single OS process at a time. Multiple Erlang processes within the same BEAM node can share a table, but opening the same file from separate BEAM nodes or OS processes can lead to corruption.

Use slate.is_dets_file to check whether a file on disk is a valid DETS file before opening it:

import slate
let assert Ok(True) = slate.is_dets_file("data/cache.dets")
let assert Ok(False) = slate.is_dets_file("README.md")

This is useful when scanning a directory for DETS files or validating user-provided paths.

FeatureDETS (slate)ETSSQLiteMnesia
Persistence Disk Memory only Disk Disk
Max size2 GBRAMUnlimitedUnlimited
Query capabilityKey lookup, foldKey lookup, match specsFull SQLMatch specs, QLC
Ordered keys (ordered_set)
External dependencyNone (OTP built-in)None (OTP built-in)YesNone (OTP built-in)
PerformanceDisk I/O boundMicrosecondsVariesVaries
Concurrent processesSingle nodeSingle nodeMultipleDistributed