Opened 16 years ago
Closed 16 years ago
#11181 closed (wontfix)
Make save faster
Reported by: | novalis | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Save presently does a bunch of work each time to set up a manager for update. This can be cached. A patch is attached.
Attachments (1)
Change History (4)
by , 16 years ago
Attachment: | faster-inserts-by-caching-manager.patch added |
---|
comment:1 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
It is in fact a fairly large percentage of the time for save in my benchmark. My case is perhaps unusual in that my model has a default ordering, but I think this is fairly common.
I can't do it in my save method, I think, because that doesn't work when I am loading fixtures. So this patch makes tests faster as well as the live site.
comment:3 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
An attribute lookup *is not that expensive* which is all this patch is doing. Marking as wontfix again, if you disagree please take this to the django-developers mailing list.
Constructing a queryset every
save()
(which your patch doesn't avoid) is not such an expensive operation that it would require caching.If you feel the need to do this in your model, do it in your
save
method and use the outcome to setforce_insert
orforce_update
.