From 19d8c7d0fd407217ca8f0f250a09dba38012beb0 Mon Sep 17 00:00:00 2001 From: jamey Date: Sun, 22 Feb 2026 09:23:41 +0000 Subject: [PATCH] tune SQLite PRAGMAs for production Add journal_size_limit (64MB), default_transaction_mode: :immediate, and mmap_size (128MB) across dev, test, and prod configs. Benchmarks showed IMMEDIATE mode eliminates transaction upgrade BUSY errors and mmap improves read throughput. Co-Authored-By: Claude Opus 4.6 --- config/dev.exs | 3 +++ config/runtime.exs | 5 ++++- config/test.exs | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/dev.exs b/config/dev.exs index a9e9d81..15877c2 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -6,6 +6,9 @@ config :berrypod, Berrypod.Repo, pool_size: 5, journal_mode: :wal, busy_timeout: 5000, + journal_size_limit: 67_108_864, + default_transaction_mode: :immediate, + custom_pragmas: [mmap_size: 134_217_728], stacktrace: true, show_sensitive_data_on_connection_error: true diff --git a/config/runtime.exs b/config/runtime.exs index e2c98c1..27f4b13 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -32,7 +32,10 @@ if config_env() == :prod do database: database_path, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "5"), journal_mode: :wal, - busy_timeout: 5000 + busy_timeout: 5000, + journal_size_limit: 67_108_864, + default_transaction_mode: :immediate, + custom_pragmas: [mmap_size: 134_217_728] # The secret key base is used to sign/encrypt cookies and other secrets. # A default value is used in config/dev.exs and config/test.exs but you diff --git a/config/test.exs b/config/test.exs index 57ab11b..58c7e6f 100644 --- a/config/test.exs +++ b/config/test.exs @@ -15,7 +15,10 @@ config :berrypod, Berrypod.Repo, journal_mode: :wal, busy_timeout: 15_000, queue_target: 5_000, - queue_interval: 10_000 + queue_interval: 10_000, + journal_size_limit: 67_108_864, + default_transaction_mode: :immediate, + custom_pragmas: [mmap_size: 134_217_728] # We don't run a server during test. If one is required, # you can enable the server option below.