mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-30 19:45:44 +00:00
fix(benchmark): reset SQLite with plain DELETEs instead of ORM deletes
The ORM path fires per-document delete signals, which is very slow at the large tier and fails when the cache backend is unreachable. Matches the TRUNCATE-based resets on the other backends. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9303f0c58
commit
5304e46d5d
1 file changed
+8
-11
@@ -73,17 +73,14 @@ def _reset_mariadb() -> None:
|
||||
|
||||
|
||||
def _reset_sqlite() -> None:
|
||||
from documents.models import Correspondent
|
||||
from documents.models import Document
|
||||
from documents.models import DocumentType
|
||||
from documents.models import StoragePath
|
||||
from documents.models import Tag
|
||||
|
||||
Document.global_objects.all().delete()
|
||||
Tag.objects.all().delete()
|
||||
Correspondent.objects.all().delete()
|
||||
DocumentType.objects.all().delete()
|
||||
StoragePath.objects.all().delete()
|
||||
# Plain DELETEs, the SQLite equivalent of the TRUNCATEs above. ORM deletes
|
||||
# fire per-document signals and cascade collection, which is far too slow
|
||||
# at the large tier and needs the cache backend to be reachable.
|
||||
# constraint_checks_disabled() mirrors MariaDB's SET FOREIGN_KEY_CHECKS = 0.
|
||||
tables = _reset_table_names()
|
||||
with connection.constraint_checks_disabled(), connection.cursor() as cursor:
|
||||
for table in tables:
|
||||
cursor.execute(f"DELETE FROM {table};")
|
||||
_delete_all_users_and_groups()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user