maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1# maddy & SQLite
 2
 3SQLite is a perfect choice for small deployments because no additional
 4configuration is required to get started. It is recommended for cases when you
 5have less than 10 mail accounts.
 6
 7**Note: SQLite requires DB-wide locking for writing, it means that multiple
 8messages can't be accepted in parallel. This is not the case for server-based
 9RDBMS where maddy can accept multiple messages in parallel even for a single
10mailbox.**
11
12## WAL mode
13
14maddy forces WAL journal mode for SQLite. This makes things reasonably fast and
15reduces locking contention which may be important for a typical mail server.
16
17maddy uses increased WAL autocheckpoint interval. This means that while
18maintaining a high write throughput, maddy will have to stop for a bit (0.5-1
19second) every time 78 MiB is written to the DB (with default configuration it
20is 15 MiB).
21
22Note that when moving the database around you need to move WAL journal (`-wal`)
23and shared memory (`-shm`) files as well, otherwise some changes to the DB will
24be lost.
25
26## Query planner statistics
27
28maddy updates query planner statistics on shutdown and every 5 hours. It
29provides query planner with information to access the database in more
30efficient way because go-imap-sql schema does use a few so called "low-quality
31indexes".
32
33## Auto-vacuum
34
35maddy turns on SQLite auto-vacuum feature. This means that database file size
36will shrink when data is removed (compared to default when it remains unused).
37
38## Manual vacuuming
39
40Auto-vacuuming can lead to database fragmentation and thus reduce the read
41performance.  To do manual vacuum operation to repack and defragment database
42file, install the SQLite3 console utility and run the following commands:
43```
44sqlite3 -cmd 'vacuum' database_file_path_here.db
45sqlite3 -cmd 'pragma wal_checkpoint(truncate)' database_file_path_here.db
46```
47
48It will take some time to complete, you can close the utility when the
49`sqlite>` prompt appears.