Code

Opened 4 years ago

Closed 4 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: UI/UX:

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()?

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by miracle2k

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 4 years ago by Alex

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 4 years ago by russellm

  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.