-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimise next prev record #791
Optimise next prev record #791
Conversation
Previously they called `.instance`, which was unnecessary as only the `_meta` was needed. By using the class itself, the need for an extra query is removed in cases where fields are excluded.
Methods are only run as test cases if they start with `test_`
Codecov Report
@@ Coverage Diff @@
## master #791 +/- ##
==========================================
+ Coverage 97.68% 97.69% +0.01%
==========================================
Files 19 19
Lines 994 999 +5
Branches 151 151
==========================================
+ Hits 971 976 +5
Misses 10 10
Partials 13 13
Continue to review full report at Codecov.
|
Fixed in e250831 |
This means history for another model doesn't appear incorrectly.
I applied the tests to 3.0.0 (master) and found them to be failing with too many queries, when I applied the changes in the pull request they correctly reduced. |
Description
Improve performance of
next_record
andprev_record
.Motivation and Context
Using
.instance
will run an additional query to get the value for fields which are excluded from history. These properties don't need that, they only need_meta
, which is accessible from the.instance_type
without running any queries.By executing fewer queries, the properties get faster. This can be especially important if the columns contain a large amount of data.
How Has This Been Tested?
I've manually applied this patch to a project, but also added relevant unit tests (and fixed an existing one which wasn't running).
Screenshots (if appropriate):
N/A
Types of changes
Checklist:
make format
command to format my codeAUTHORS.rst
CHANGES.rst