SQLite
SQLite is an embedded SQL database stored in a single file. Like RocksDB, it runs inside the Stalwart process and needs no separate service. Its particular advantage is the single file, which is easy to copy and to inspect with standard tools. The file can also be replicated continuously to object storage with external tools such as Litestream. SQLite suits small single-node installations.
Only one process at a time opens an SQLite database, so several Stalwart nodes cannot share an SQLite data store. A cluster uses PostgreSQL, MySQL or FoundationDB instead.
Configuration
Section titled “Configuration”The backend is selected with the Sqlite variant of the DataStore object (found in the WebUI under Settings › Storage › Data Store). path is the location of the database file, which is created if it does not exist.
Database operations run on a pool of threads, whose size is set by poolWorkers. When the field is unset, the pool has as many threads as the host has processor cores, with a minimum of 4.
The number of open connections to the database is limited separately, by poolMaxConnections. When it is unset, it equals poolWorkers, kept between 4 and 16. This setting also affects memory, because each connection keeps its own page cache of 32 MiB. The connection count therefore determines part of the memory used by the server, as discussed in Tuning the data store.
The following data store uses the file /var/lib/stalwart/stalwart.db:
{ "@type": "Sqlite", "path": "/var/lib/stalwart/stalwart.db"}Disk space
Section titled “Disk space”When data is deleted, SQLite reuses the freed space for new data, but the database file itself does not shrink. To reduce its size, stop the server and run VACUUM on the file, as described in Data retention and reclaiming disk space.