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

Speed up email query #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Speed up email query #359

wants to merge 1 commit into from

Conversation

mveytsman
Copy link
Contributor

@phillmv the query you asked me to look at came from the EmailManager which found every user that had outstanding notifications that wanted them before building a vuln/patched email for each of those users.

In building the email, we query the notifications table again for each account:

unnotified_logs = VulnQuery.new(acct).unnotified_vuln_logs.where("log_bundle_vulnerabilities.created_at >= ? ", 2.days.ago)
# ...
if unnotified_logs.any?
        email = EmailVulnerable.create!(:account => acct)

Seeing that, it seems like the fastest fix here is to just get rid of the the slow query that tries to guess which accounts have notifications to send and just do the faster query (scoped to the last 2 days of events) for every account.

Can you sanity check this?

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.

1 participant