optimise the subject workflow status by_set query (#2665)
optimise the subject workflow status by_set query (#2665)

* optimise the subject workflow status by set query

avoid joins for this query as they do not use the subject_id index, moving to a CTE that allows the subselect to access the subject_id index. CTE’s create temp tables for single queries effectively exploding the find all subjects for this set to be used in a subquery IN operation.

Benchmarking shows a massive improvement when accessing the index ~15-20x.

* match SetMemberSubject subject_set_id via IN clause

allow lists to match the subject_set_id not just ints

* remove extra arel statement

camallen/Panoptes,camallen/Panoptes,camallen/Panoptes,camallen/Panoptes,zooniverse/Panoptes,zooniverse/Panoptes,zooniverse/Panoptes,zooniverse/Panoptes