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
Fixes #1592: making report::expire faster and without errors #1659
Conversation
I'd like to test it on real reports but for now on 5000 generated reports I used: before change: after change: |
Something else to measure will be the memory usage, as that's been a common complaint about reports:expire and it looks like the original code was attempting to keep it down (successfully or not, I'm unsure). |
@domcleal I used The results: after change: |
all_sources = Source.pluck(:id) | ||
orphaned_sources = all_sources - used_sources | ||
Source.where(:id => orphaned_sources).delete_all unless orphaned_sources.empty? | ||
count = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why initializing it to 0?
count = Report.where(cond).delete_all
should do.
👍 except for the code nitpicks, even if it was a tad slower I'd favor this as it's considerably simpler to understand and maintain. |
@elobato sorry, those where leftovers from the previous code. |
I'm testing memory usage for 10k reports before merging. |
@elobato thanks! |
all_sources = Source.pluck(:id) | ||
orphaned_sources = all_sources - used_sources | ||
Source.where(:id => orphaned_sources).delete_all unless orphaned_sources.empty? | ||
Message.joins(:logs).joins(:reports).where(cond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused query
@elobato these are the test results for 10k before change: after change: |
[test] |
[test] |
@elobato can you please recheck this? |
No description provided.