1
Fork 0

Optimise DB after insert

This commit is contained in:
Jake Howard 2024-08-24 16:42:03 +01:00
parent 9e20691b34
commit d43cfd2224
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 5 additions and 0 deletions

View file

@ -33,5 +33,9 @@ class CoreConfig(AppConfig):
def post_save(self, sender, instance, created, **kwargs):
if not created:
return
with connections["default"].cursor() as cursor:
cursor.execute("INSERT INTO search_index(body, rowid) VALUES (%s, %s)", [strip_tags(instance.content), instance.pk])
with connections["default"].cursor() as cursor:
cursor.execute("PRAGMA optimise;")

View file

@ -72,6 +72,7 @@ PRAGMA synchronous=OFF;
PRAGMA mmap_size = 134217728;
PRAGMA cache_size=4000;
PRAGMA temp_store=MEMORY;
PRAGMA auto_vacuum=INCREMENTAL;
"""
DATABASES = {