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

[fix] Better SQL SELECT instead of a timeout query #4363

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

bruntib
Copy link
Contributor

@bruntib bruntib commented Oct 14, 2024

This query runs when filtering by files or components with "anywhere on bugpath" option. In this case the following query was generated:

SELECT <columns> FROM reports WHERE reports.id IN (id1, id2, ...);

The ID list at "IN" block can be so huges that it eats up all the memory and times out the query. This ID list is now replaced with a nested select:

SELECT <columns> FROM reports WHERE reports.id IN (SELECT report_id FROM <some tables>);

This query runs when filtering by files or components with "anywhere
on bugpath" option. In this case the following query was generated:

SELECT <columns> FROM reports WHERE reports.id IN (id1, id2, ...);

The ID list at "IN" block can be so huges that it eats up all the memory
and times out the query. This ID list is now replaced with a nested
select:

SELECT <columns> FROM reports WHERE reports.id IN
  (SELECT report_id FROM <some tables>);
@bruntib bruntib added database 🗄️ Issues related to the database schema. bugfix 🔨 performance 🏃 labels Oct 14, 2024
@bruntib bruntib added this to the release 6.25.0 milestone Oct 14, 2024
@bruntib bruntib requested a review from cservakt October 14, 2024 11:05
@bruntib bruntib requested a review from vodorok as a code owner October 14, 2024 11:05
@cservakt
Copy link
Collaborator

cservakt commented Oct 17, 2024

I am not sure using in operator is the best solution. What if we join all the tables to the reports like this:

SELECT <columns> FROM reports INNER JOIN files ON reports.file_id = files.id LEFT JOIN bug_path_events ON bug_path_events.file_id = files.id LEFT JOIN bug_report_point ON bug_report_point.file_id = files.id LEFT JOIN extended_report_data ON extended_report_data.file_id = files.id WHERE <file_filters> AND (bug_path_events.id IS NOT NULL OR bug_report_point.id IS NOT NULL OR extended_report_data.id IS NOT NULL);

@bruntib bruntib merged commit aea1783 into Ericsson:master Oct 21, 2024
7 of 8 checks passed
@bruntib bruntib deleted the better_sql_select branch October 21, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 database 🗄️ Issues related to the database schema. performance 🏃
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants