Optimization of buildrepo queries. And also, always look for 'empties' before 'oldies'.