mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Tune SQLite settings for using SQLite in production for small sites
See: https://fractaledmind.github.io/2023/09/07/enhancing-rails-sqlite-fine-tuning/
This commit is contained in:
parent
ca5f2da34a
commit
877ffc0741
2
.gitignore
vendored
2
.gitignore
vendored
@ -114,3 +114,5 @@ node_modules
|
||||
.vscode
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
/db.sqlite3-*
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
from django.db.backends.signals import connection_created
|
||||
def configure_sqlite_web_settings(sender, connection, **kwargs):
|
||||
"""Configure sqlite for web application use."""
|
||||
if connection.vendor == 'sqlite':
|
||||
cursor = connection.cursor()
|
||||
cursor.execute('PRAGMA journal_mode = WAL;')
|
||||
cursor.execute('PRAGMA synchronous = NORMAL;')
|
||||
cursor.execute('PRAGMA journal_size_limit = 67108864; -- 64 megabytes')
|
||||
cursor.execute('PRAGMA mmap_size = 134217728; -- 128 megabytes')
|
||||
cursor.execute('PRAGMA cache_size = 2000; -- 2000 pages')
|
||||
cursor.execute('PRAGMA busy_timeout = 5000;')
|
||||
|
||||
connection_created.connect(configure_sqlite_web_settings)
|
Loading…
Reference in New Issue
Block a user