Use matrix.map(&:id) when selecting matrix_ids to mitigate jdbc errors