Deleting a document unnecessarily scans all annotations #2889

Closed
opened 2016-02-26 11:26:35 +00:00 by wjt · 3 comments

There is a pre_delete handler for Document which deletes the document's file. FileField.delete() will, by default, save() the model instance it is attached to. This is pointless if we're in the process of deleting the Document – and since Document.save() calls Document.update_matches(), this scans all annotations every time a document is deleted.

There is a `pre_delete` handler for `Document` which deletes the document's file. `FileField.delete()` will, by default, `save()` the model instance it is attached to. This is pointless if we're in the process of deleting the `Document` – and since `Document.save()` calls `Document.update_matches()`, this scans all annotations every time a document is deleted.
wjt added the
backend
label 2016-02-26 11:26:35 +00:00
wjt added this to the 14.04 milestone 2016-02-26 11:26:35 +00:00
j was assigned by wjt 2016-02-26 11:26:35 +00:00
wjt added the
normal
enhancement
labels 2016-02-26 11:26:35 +00:00
Author
3 commits on <https://gitlab.com/wjt/pandora.git> branch 2889-dont-save-on-delete Diff: <https://gitlab.com/wjt/pandora/compare/master...2889-dont-save-on-delete>
Author

In this brave new Django 1.9 future, these pre_delete hooks might want to use on_commit to defer deleting the files until the transaction is committed: https://docs.djangoproject.com/en/1.9/topics/db/transactions/#performing-actions-after-commit

In this brave new Django 1.9 future, these `pre_delete` hooks might want to use `on_commit` to defer deleting the files until the transaction is committed: <https://docs.djangoproject.com/en/1.9/topics/db/transactions/#performing-actions-after-commit>
Owner

In 6e0049a/pandora:

#!CommitTicketReference repository="pandora" revision="6e0049a20c8476dde978227a8c49e42bcca2d1d3"
Don't save Document in pre_delete handler (fixes #2889)

FileField.delete() will, by default, save() the model instance it is
attached to. This is pointless if we're in the process of deleting the
Document -- and since Document.save() calls Document.update_matches(),
this scans all annotations every time a document is deleted.
In [6e0049a/pandora](https://code.0x2620.org/0x2620/pandora/commit/6e0049a20c8476dde978227a8c49e42bcca2d1d3): ``` #!CommitTicketReference repository="pandora" revision="6e0049a20c8476dde978227a8c49e42bcca2d1d3" Don't save Document in pre_delete handler (fixes #2889) FileField.delete() will, by default, save() the model instance it is attached to. This is pointless if we're in the process of deleting the Document -- and since Document.save() calls Document.update_matches(), this scans all annotations every time a document is deleted. ```
0x2620 added the
fixed
label 2016-03-03 12:41:39 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: 0x2620/pandora#2889
No description provided.