QuizzesFetch Joins & the N+1 Problem — Concept Check
intermediate
hibernate

Fetch Joins & the N+1 Problem — Concept Check

Questions on Fetch Joins & the N+1 Problem. JOIN FETCH in JPQL or EntityGraph with FETCH eagerly initialises associations in a single query; beware the Cartesian product explosion when fetching multiple collections simultaneously.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Fetch Joins & the N+1 Problem — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer notices that fetching 100 orders results in 101 SQL queries. What could be the cause?

    • ASubselect fetching is disabled
    • BN+1 problem due to lazy loading
    • CIncorrect JOIN FETCH usage
    • DBatchSize not configured
  2. 2.You use JOIN FETCH to load multiple @OneToMany collections and notice a performance drop. Why?

    • ABatchSize not set
    • BCartesian product explosion
    • CSubselect fetching needed
    • DN+1 problem
  3. 3.A query with JOIN FETCH is returning duplicate results. What might be the issue?

    • AJOIN FETCH multiplies rows
    • BSubselect fetching is disabled
    • CBatchSize too small
    • DN+1 problem
  4. 4.What is a potential downside of using JOIN FETCH with multiple collections?

    • AIncreases BatchSize
    • BCreates Cartesian product
    • CCauses N+1 problem
    • DDisables lazy loading
  5. 5.A developer uses @EntityGraph but still sees multiple queries. What might they have missed?

    • ADisabled lazy loading
    • BIncorrect attribute paths
    • CNot using BatchSize
    • DUsing SELECT DISTINCT
  6. 6.Using JOIN FETCH on a @OneToMany association causes a large number of rows. What is a better approach?

    • ADisable JOIN FETCH
    • BEnable lazy loading
    • CUse @BatchSize
    • DUse more JOIN FETCH
  7. 7.Why might enabling spring.jpa.show-sql=true be useful during development?

    • ATo count SQL queries
    • BTo improve performance
    • CTo enable lazy loading
    • DTo configure BatchSize