Using a cache and grouped data fetching to avoid superfluous queries