Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

2 million records from oracle database

 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Question 1:
How do I fetch 2 million records from database ?


Question 2 :

How do I remove duplicate values in one of the fields? Can I use hashset?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose it depends on how much memory you have, and how big the rows are.
You could just query them as normal, assuming you have enough memory, but it would probably be better to page them, or use a cursor to stream them.
Using a Set for 2 million objects might not be the best idea, you may want to use a distinct or group by on the database instead.
Depending on what you are doing with the objects, you may also consider using a JPQL Update query instead.

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Pagination
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!