Skip to content

Conversation

@marko90b
Copy link

When field is a relation get_field_value requires at least 2 additional queries to database. If str method of related object contains further relations, much more queries might be required. Accessing internal attribute (field.attname, usually f'{field.name}_id'), however, doesn't require any additional database queries. Only when model_delta determines the field really changed, string representation of the related objects are obtained by querying database. This can increase time needed to save lots of objects (>100) in the same view, when these objects have many relations, but not many (if any) of them changed.

When field is a relation `get_field_value` requires at least 2 additional queries to database. If __str__ method of related object contains further relations, much more queries might be required. Accessing internal attribute (`field.attname`, usually `f'{field.name}_id'`), however, doesn't require any additional database queries. Only when `model_delta` determines the field really changed, string representation of the related objects are obtained by querying database. This can increase time needed to save lots of objects (>100) in the same view, when these objects have many relations, but not many (if any) of them changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant