Opened 11 years ago

Closed 11 years ago

#12172 closed (duplicate)

Improve save() handling of deferred fields

Reported by: miracle2k Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Currently, when saving a model instance with deferred fields, all the missing fields are first pulled, one query each. This is not only very inefficient, of course, it also restricts the number of possible uses of the defer mechanism.

For example, django-denorm needs to do an additional query when saving a model with cache-fields to ensure that a potentially more recent value in the db is not overridden with a stale value on the field. If a field could just be excluded from save(), that would not be necessary.

I'm not familiar with the Django ORM code, but wouldn't it be straightforward to just skip fields that are not yet loaded during a save()?

Change History (3)

comment:1 Changed 11 years ago by miracle2k

FWIW, here's a reference to the django-denorm ticket:

comment:2 Changed 11 years ago by Alex Gaynor

This basically blocks on #4102. I'm not going to close it as a dupe because technically this is just something that should be done once that's in.

comment:3 Changed 11 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

I agree with alex - this is essentially a logical consequence of implementing #4102.

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