From 9e20691b348b605906b72173e9ddc20e24a546f7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 24 Aug 2024 16:35:12 +0100 Subject: [PATCH] Optimise SQLite for reads --- yamdl_playground/settings.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/yamdl_playground/settings.py b/yamdl_playground/settings.py index accf7b4..f054a8d 100644 --- a/yamdl_playground/settings.py +++ b/yamdl_playground/settings.py @@ -66,16 +66,30 @@ WSGI_APPLICATION = 'yamdl_playground.wsgi.application' # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases +db_init_command = """ +PRAGMA journal_mode=OFF; +PRAGMA synchronous=OFF; +PRAGMA mmap_size = 134217728; +PRAGMA cache_size=4000; +PRAGMA temp_store=MEMORY; +""" + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'file:default-db?mode=memory&cache=shared', - "CONN_MAX_AGE": 600 + "CONN_MAX_AGE": 600, + "OPTIONS": { + "init_command": db_init_command + } }, 'yamdl': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'file:yamdl-db?mode=memory&cache=shared', - "CONN_MAX_AGE": 600 + "CONN_MAX_AGE": 600, + "OPTIONS": { + "init_command": db_init_command + } } }