-1

I want to request a high amount of records (100000 to 1000000) per select request with a join of three tables. Is the performance much better with nativeSQL instead of using spring-data-jpa for mapping it to @Entity objects?

Thx!

Gerrit
  • 2,515
  • 5
  • 38
  • 63
  • Querying this amount of data will have an impact in performance and memory, regardless whether it native or jpa. You should consider use pagination – Melad Basilius Jul 20 '19 at 09:24
  • Yes, the 100000 will be the size of the package. The complete amount of records that must be migrated is near 70,000,000,000 – Gerrit Jul 20 '19 at 09:26

1 Answers1

0

JPA and every ORM turn your query results into domain objects. That of course takes resources. Spring Data JPA adds potential conversions to that and it preprocesses your query in order to support fancy ways of setting parameters.

If you are selecting large amounts of data the preprocessing of the statement probably doesn't matter that much. But the conversion to domain objects will.

You used the word "migrating" which sounds like you are going to select data and then immediately write it somewhere else. If that is the case, use plain SQL and work directly on the ResultSet tell the driver to make it read only and forward only. See Understanding Forward Only ResultSet

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348