Reduced db queries in categories view