From dbf2f37cc9f54d7b77772b268c64a0ebfd008089 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sat, 7 Nov 2026 08:27:03 +0900 Subject: [PATCH] Fix slow issue search within a project on MariaDB Passing project ids to a string condition makes MySQL adapters quote them as strings (e.g. "issues.project_id IN ('1')"). When searching within a single project, MariaDB does not treat the quoted value as a constant for the projects table and scans the whole issues table, which makes searching custom fields within a large project very slow. Use a hash condition so that the ids are passed as integers. Co-Authored-By: Claude Opus 5.5 --- lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb index fd7a11707..6276ceaaf 100644 --- a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb +++ b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb @@ -202,7 +202,7 @@ module Redmine end if projects - scope = scope.where("#{searchable_options[:project_key]} IN (?)", projects.map(&:id)) + scope = scope.where(searchable_options[:project_key] => projects.map(&:id)) end scope end -- 2.55.0