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

[server] Add index for report and run history id columns #3351

Conversation

csordasmarton
Copy link
Contributor

Removing a run got slow after we introduced the analysis info table
in the previous 6.16.0. CodeChecker release. Doing some measurement
on the database I tried to run the following query:

begin;
explain (analyze,buffers,timing) delete from runs where id=1;
rollback;

The output looked like this:

 QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
 Delete on runs  (cost=0.00..1.51 rows=1 width=6) (actual time=0.048..0.050 rows=0 loops=1)
   Buffers: shared hit=3
   ->  Seq Scan on runs  (cost=0.00..1.51 rows=1 width=6) (actual time=0.020..0.024 rows=1 loops=1)
         Filter: (id = 1
         Rows Removed by Filter: 40
         Buffers: shared hit=1
 Planning Time: 0.077 ms
 Trigger for constraint fk_reports_run_id_runs on runs: time=1.728 calls=1
 Trigger for constraint fk_run_histories_run_id_runs on runs: time=0.062 calls=1
 Trigger for constraint fk_bug_path_events_report_id_reports on reports: time=23.935 calls=578
 Trigger for constraint fk_bug_report_points_report_id_reports on reports: time=7.960 calls=578
 Trigger for constraint fk_extended_report_data_report_id_reports on reports: time=6.060 calls=578
 Trigger for constraint fk_report_analysis_info_report_id_reports on reports: time=22042.053 calls=578
 Trigger for constraint fk_analyzer_statistics_run_history_id_run_histories on run_histories: time=0.046 calls=2
 Trigger for constraint fk_run_history_analysis_info_run_history_id_run_histories on run_histories: time=0.033 calls=2
 Execution Time: 22082.691 ms

From this we can see that the bottleneck is the
fk_report_analysis_info_report_id_reports contstraint. Adding indices on
the report_id and run_history_id columns on the join tables (report_analysis_info,
run_history_analysis_info`) solves this problem and reduces the amount of query
time drastically.

Removing a run got slow after we introduced the analysis info table
in the previous 6.16.0. CodeChecker release. Doing some measurement
on the database I tried to run the following query:
```sh
begin;
explain (analyze,buffers,timing) delete from runs where id=1;
rollback;
```

The output looked like this:
```
 QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
 Delete on runs  (cost=0.00..1.51 rows=1 width=6) (actual time=0.048..0.050 rows=0 loops=1)
   Buffers: shared hit=3
   ->  Seq Scan on runs  (cost=0.00..1.51 rows=1 width=6) (actual time=0.020..0.024 rows=1 loops=1)
         Filter: (id = 1
         Rows Removed by Filter: 40
         Buffers: shared hit=1
 Planning Time: 0.077 ms
 Trigger for constraint fk_reports_run_id_runs on runs: time=1.728 calls=1
 Trigger for constraint fk_run_histories_run_id_runs on runs: time=0.062 calls=1
 Trigger for constraint fk_bug_path_events_report_id_reports on reports: time=23.935 calls=578
 Trigger for constraint fk_bug_report_points_report_id_reports on reports: time=7.960 calls=578
 Trigger for constraint fk_extended_report_data_report_id_reports on reports: time=6.060 calls=578
 Trigger for constraint fk_report_analysis_info_report_id_reports on reports: time=22042.053 calls=578
 Trigger for constraint fk_analyzer_statistics_run_history_id_run_histories on run_histories: time=0.046 calls=2
 Trigger for constraint fk_run_history_analysis_info_run_history_id_run_histories on run_histories: time=0.033 calls=2
 Execution Time: 22082.691 ms
```

From this we can see that the bottleneck is the
 `fk_report_analysis_info_report_id_reports` contstraint. Adding indices on
the `report_id` and `run_history_id` columns on the join tables (`report_analysis_info`,
run_history_analysis_info`) solves this problem and reduces the amount of query
time drastically.
@csordasmarton csordasmarton added database 🗄️ Issues related to the database schema. server 🖥️ performance 🏃 labels Jun 10, 2021
@csordasmarton csordasmarton added this to the release 6.17.0 milestone Jun 10, 2021
@bruntib bruntib merged commit 123ae58 into Ericsson:master Jun 11, 2021
@csordasmarton csordasmarton deleted the add_index_for_report_and_history_id_columns branch January 28, 2022 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database 🗄️ Issues related to the database schema. performance 🏃 server 🖥️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants