Opened 15 years ago

Closed 15 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

Description

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 by miracle2k, 15 years ago

FWIW, here's a reference to the django-denorm ticket: http://github.com/initcrash/django-denorm/issues/#issue/4

comment:2 by Alex Gaynor, 15 years ago

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 by Russell Keith-Magee, 15 years ago

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