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 result counting #1361

Merged
merged 6 commits into from
Nov 24, 2020

Conversation

mattmundell
Copy link
Contributor

@mattmundell mattmundell commented Nov 23, 2020

What:

Speed up result counting iterator.

2 parts:

  1. Use result_new_severities_dynamic/result_new_severities_static instead of result_new_severities when the dynamic state is known.
  2. Use LATERAL to save having the severity calculation repeated in the WHERE clause (where it was not accessing the WITH optimisations).

Test case was an --optimize rebuild-report-cache that took 32s on master.

With 1 the test case dropped to 23s, with 1 and 2 it dropped to under 4s.

Why:

Immediate problem: Result counting slows down the report upload used to generate big dbs.

How did you test it:

  1. time gvmd --optimize rebuild-report-cache on master (32s)
  2. psql gvmd -c "SELECT report, user, severity, count, override, end_time, min_qod from report_counts;" > /tmp/rc_master
  3. time gvmd --optimize rebuild-report-cache with patch (4s)
  4. psql gvmd -c "SELECT report, user, severity, count, override, end_time, min_qod from report_counts;" | sort > /tmp/rc_pr
  5. sort /tmp/rc_master | diff - /tmp/rc_pr (same)

Checklist:

@mattmundell mattmundell marked this pull request as ready for review November 23, 2020 13:21
Copy link
Member

@timopollmeier timopollmeier left a comment

Choose a reason for hiding this comment

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

I can confirm that it speeds up the cache rebuild a lot and uploading reports feels faster as well.

@timopollmeier timopollmeier merged commit b79ba23 into greenbone:master Nov 24, 2020
@mattmundell mattmundell deleted the report-count-speed-2 branch November 24, 2020 10:02
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.

2 participants