X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/46a90d7cfe54bb6df2f99175abd0ad7d26b3da72..560fda9dbc19a0019af8449b3d3393305fffa743:/apps/catalogue/utils.py diff --git a/apps/catalogue/utils.py b/apps/catalogue/utils.py index 1ac0ee8d8..106067092 100644 --- a/apps/catalogue/utils.py +++ b/apps/catalogue/utils.py @@ -300,3 +300,16 @@ class AppSettings(object): if hasattr(self, more): value = getattr(self, more)(value) return value + + +def trim_query_log(trim_to=25): + """ +connection.queries includes all SQL statements -- INSERTs, UPDATES, SELECTs, etc. Each time your app hits the database, the query will be recorded. +This can sometimes occupy lots of memory, so trim it here a bit. + """ + if settings.DEBUG: + from django.db import connection + connection.queries = trim_to > 0 \ + and connection.queries[-trim_to:] \ + or [] +