Multiple choice technology programming languages

If instances are not in the session or second-level cache which will give better performance?

  1. a) Query.list()

  2. b) Query.iterate()

  3. c) Both are same

  4. d) None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

When instances are not in session or second-level cache, Query.list() performs better than Query.iterate(). Query.list() fetches all data in a single SQL query, while Query.iterate() first loads identifiers then loads each entity individually (N+1 queries problem), causing multiple database round-trips.