DB query performance improvements