0

I have a MySQL table with 27 columns and more than 1 million rows. I want to fetch the complete data from the table, which makes my query - select * from table;

I do this through java Prepared statmennts and ResultSet. How can I optimize this operation. Some kind of batching will be helpful or should I proceed with some other technique?

Could you please advise.

pnv
  • 1,437
  • 3
  • 23
  • 52
  • seriously? you are trying to fetch million of records? you should look into pagination or batches – meda Sep 10 '14 at 03:53
  • 1
    For what purpose? If it's for an update, the best bet is not to fetch them at all, but to express the update as a single UPDATE statement, and have all the work done by the database. Transporting a million rows back and forth cannot possibly be fast. – user207421 Sep 10 '14 at 03:54
  • 1
    Your question is too vague to have an answer at this point. We need to understand what you're going to do with the rows of data (read only? update?) – Jim Garrison Sep 10 '14 at 04:36
  • Thanks for the responses. I want to fetch the data from one mysql table, add them into MongoDB through Java. – pnv Sep 10 '14 at 06:29
  • OK, now why through Java? You should be able to accomplish that via dump and restore tools. – user207421 Sep 10 '14 at 07:25
  • @EJP - This is the technique which is in place as of now. I can discuss with the senior team members about using dump and restore tools. – pnv Sep 10 '14 at 07:57
  • It's not 'in place now' if you're asking how best to do it. – user207421 Sep 10 '14 at 23:40

0 Answers0