ALM-167 removed with_errors source status to speed up admin dashboard
ALM-167 small optimizations of SQL queries for retrieval_histories