Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix[Op#54459]: Remove unnecessary distinct in subselect that degrades performance

Kabiru Mwenja30067c27fef0
diff --git a/app/models/projects/scopes/available_custom_fields.rb b/app/models/projects/scopes/available_custom_fields.rb
index 5122b78038b..5ce046be42b 100644
--- a/app/models/projects/scopes/available_custom_fields.rb
+++ b/app/models/projects/scopes/available_custom_fields.rb
@@ -46,7 +46,6 @@ module Projects::Scopes
def project_custom_fields_project_mapping_subquery(custom_field_ids:)
ProjectCustomFieldProjectMapping.select(:project_id)
.where(custom_field_id: custom_field_ids)
- .distinct
end
end
end
diff --git a/spec/models/queries/projects/filters/available_project_attributes_filter_spec.rb b/spec/models/queries/projects/filters/available_project_attributes_filter_spec.rb
index 466a9edea7e..e7c8eb200d7 100644
--- a/spec/models/queries/projects/filters/available_project_attributes_filter_spec.rb
+++ b/spec/models/queries/projects/filters/available_project_attributes_filter_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe Queries::Projects::Filters::AvailableProjectAttributesFilter do
let(:project_custom_field_project_mapping_handwritten_sql_subquery) do
<<-SQL.squish
- SELECT DISTINCT "project_custom_field_project_mappings"."project_id"
+ SELECT "project_custom_field_project_mappings"."project_id"
FROM "project_custom_field_project_mappings"
WHERE "project_custom_field_project_mappings"."custom_field_id"
IN (#{values.join(', ')})