Speed up result counting iterator #1358
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What:
Speed up iterator created by init_result_get_iterator_severity.
Tests indicate about a 4x increase in result counting speed (for report counts cache).
Why:
Faster.
How did you test it:
On master:
time gvmd --optimize rebuild-report-cache
=> 280malter table report_counts rename to report_counts_master;
drop index report_counts_by_report_and_override;
CREATE TABLE IF NOT EXISTS report_counts (id SERIAL PRIMARY KEY, report integer REFERENCES reports (id) ON DELETE RESTRICT, "user" integer REFERENCES users (id) ON DELETE RESTRICT, severity decimal, count integer, override integer, end_time integer, min_qod integer);
time gvmd --optimize rebuild-report-cache
=> 77mselect count(*) from report_counts;
=> 21280select count(*) from report_counts_master;
=> 21280select report, user, severity, count, override, end_time, min_qod from report_counts_master EXCEPT select report, user, severity, count, override, end_time, min_qod from report_counts;
=> 0 rowsChecklist: