0

In spring batch reference, there is a pattern called driving query pattern https://docs.spring.io/spring-batch/4.1.x/reference/html/common-patterns.html#drivingQueryBasedItemReaders

I don't know if I misunderstand this pattern right, doesn't driving query pattern cause N+1 problem?

It looks like a classic N+1 problem to me, especially they are bad practice in ORM world.

min
  • 953
  • 1
  • 11
  • 23

1 Answers1

2

Yes it does. For each item, the processor will issue another query to grab additional information about the current item.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50
  • Then why spring batch doing that? – min Jul 23 '19 at 08:52
  • Spring Batch does not do that, you do it if you want using Spring Batch. It is a pattern like any other pattern. Now even if this pattern may introduce a performance issue with large data sets, it could also work perfectly fine for most use cases having medium/small data sets. – Mahmoud Ben Hassine Jul 23 '19 at 10:25