-
-
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
Use exists() instead of count() in populate_history command #922
Comments
Sounds reasonable to me. Is there an existing test that covers this code path? |
I believe so. There is a PopulateHistory TestCase
with a specific test with existing objects:
|
Feel free to open a pull request to make this change. |
11 tasks
This can probably be closed, it has been released in 3.2.0 through the aforementioned MR. |
I agree, closing 🙂 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem Statement
The
populate_history
commands take a long time to run when history tables have many rows, mainly because of thecount()
query that checks if the history already exists:django-simple-history/simple_history/management/commands/populate_history.py
Line 159 in 0f5e159
Describe the solution you'd like
I am wondering if the
count()
query could be changed toexists()
instead. Since the count is only used to check if it returns a truthy value, I believe exists would be a better fit and faster to run. If that is ok, I am happy to send a PR.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: