Optimize retrieval of entities