Skip to content
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

Closed
fabiocapsouza opened this issue Nov 25, 2021 · 5 comments
Closed

Use exists() instead of count() in populate_history command #922

fabiocapsouza opened this issue Nov 25, 2021 · 5 comments

Comments

@fabiocapsouza
Copy link

Problem Statement
The populate_history commands take a long time to run when history tables have many rows, mainly because of the count() query that checks if the history already exists:

Describe the solution you'd like
I am wondering if the count() query could be changed to exists() 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

@jeking3
Copy link
Contributor

jeking3 commented Dec 13, 2021

Sounds reasonable to me. Is there an existing test that covers this code path?

@fabiocapsouza
Copy link
Author

I believe so. There is a PopulateHistory TestCase

class TestPopulateHistory(TestCase):

with a specific test with existing objects:

def test_existing_objects(self):

@jeking3
Copy link
Contributor

jeking3 commented Jan 18, 2022

Feel free to open a pull request to make this change.

@Greg-Hamel
Copy link

This can probably be closed, it has been released in 3.2.0 through the aforementioned MR.

@ddabble
Copy link
Member

ddabble commented Aug 25, 2023

I agree, closing 🙂

@ddabble ddabble closed this as completed Aug 25, 2023
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

No branches or pull requests

4 participants