ORM: optimized slow query