Currently, the measure filter service is executing a first SQL query in Java (to get the list of components) and then the rest is done on Rails side, most notably:
SELECT * FROM `snapshots` WHERE id in (.....)
SELECT * FROM `projects` WHERE (`projects`.`id` IN (...) OR `projects`.`id` IN (...) OR .....)
SELECT * FROM `project_measures` WHERE (rule_priority is null and rule_id is null and characteristic_id is null and person_id is null and snapshot_id in (....) and metric_id in (....))
We have to fix queries on snapshots and project_measures to split in (...) in group of max 1000 elements.