Opened 9 years ago

Closed 9 years ago

#11181 closed (wontfix)

Make save faster

Reported by: novalis Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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)

faster-inserts-by-caching-manager.patch (1.2 KB) - added by novalis 9 years ago.

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by novalis

comment:1 Changed 9 years ago by Honza Král

Resolution: wontfix
Status: newclosed

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 set force_insert or force_update.

comment:2 Changed 9 years ago by novalis

Resolution: wontfix
Status: closedreopened

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 Changed 9 years ago by Alex Gaynor

Resolution: wontfix
Status: reopenedclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top