optimize table joins for faster counting performance
Tests shows that changing inner joins to left outer joins on non-null fields will significantly improve the counting performance on PostgreSQL server 9.X.
Only large tables (task, build, and rpminfo) are involved in this commit.