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

Sync versions: little optimization when deleting versions #7367

Merged
merged 1 commit into from Aug 18, 2020

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Aug 6, 2020

According to django's docs, using count/exists will
do one query and another one when fetching the results.

So is better to just fetch the results if you are going to
fetch the results anyway.

And here doing two queries means sending a loooooong query twice.

According to django's docs, using count/exists will
do one query and another one when fetching the results.

So is better to just fetch the results if you are going to
fetch the results anyway.

And here doing two queries means sending a loooooong query twice.
@stsewd stsewd requested a review from a team Aug 6, 2020
Copy link
Member

@humitos humitos left a comment

Seems good to me. We are not changing the query, but how we do the "count". After adding a comment about this in the code, we are ready to merge.

ret_val = set(to_delete_qs.values_list('slug', flat=True))
if ret_val:
Copy link
Member

@humitos humitos Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good if you write a comment here about why we don't use .count() as it was.

Copy link
Member Author

@stsewd stsewd Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary, I'm planning in revising the whole code base for places where we use exists or count and later we evaluate the values.

@stsewd stsewd merged commit de4d0bf into master Aug 18, 2020
2 checks passed
@stsewd stsewd deleted the optimize-delete-versions branch Aug 18, 2020
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.

None yet

2 participants