#12581: connection.queries should use a ring buffer to avoid large memory
consumption under runserver
-------------------------------------+-------------------------------------
Reporter: robhudson | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin
Comment:
I'm going to complete this patch. However, an important aspect hasn't been
considered yet. `connection.queries` is documented in faq/models.txt as "a
list of dictionaries in order of query execution". We cannot change its
type.
To preserve it, we can use a deque internally and provide a `queries`
property that turns the deque into a list. The property should also emit a
warning when the limit is reached and queries are truncated.
This requires making `connection.queries` read-only. I suspect some people
use `connection.queries = []` to reset queries, even though the
documentation only talks about `db.reset_queries()`. But since there's a
documented API, I don't feel too bad about breaking undocumented usage.
I've set a high limit to minimize chances that people will hit it -- if
it's over 9000, you're really in trouble -- and I've made it a class
attribute to make it possible to change.
Pull request: https://github.com/django/django/pull/2772
--
Ticket URL: <https://code.djangoproject.com/ticket/12581#comment:21>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.74d92011a09d06effd327b14946b3499%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.