Skip to main content

Query Optimization, Indexing, Read-Only Queries and Avoiding Eager Loading

Learn Query Optimization, Indexing, Read-Only Queries and Avoiding Eager Loading (Phase 7 · Hibernate Performance Optimization (Essential), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Query optimisation checklist • Select only what you need : DTO/interface projections for lists; avoid loading entities for read-only screens. Fetch what you need in one go : fetch joins/entity graphs/batch size. Paginate everything user-facing; never return unbounded lists. • Avoid findAll() on big tables, count() on huge tables per request (cache or approximate), functions on indexed columns in where ( lower(email) defeats an index unless a functional index exists), like '%text' (leading wildcard), or chains, select distinct on big graphs, and in with thousands of values (chunk it). • Prefer...

More lessons in Phase 7 · Hibernate Performance Optimization (Essential)