0

As you see the title, I would be glad to hear your answers about which one is more convenient for performance as SELECTing huge data from db!

Which is the best to prefer for which cases and why?

(PS: There is not any mapping relation like one-to-many etc. Just selecting rows from a single but huge table including millions of data -mysql-)

Thanks in advance.

javatar
  • 4,542
  • 14
  • 50
  • 67

1 Answers1

2

Normally the mysql-connector will retrieve all of the results into memory and then you navigate through these results in memory. Of course this is bad.

A work-around is to call statement.setFetchSize(Integer.MIN_VALUE) which makes it retrieve one at a time. This makes the performance worse but it won't consume so much memory.

More detail here: http://bugs.mysql.com/bug.php?id=18148

Alex
  • 367
  • 1
  • 3
  • 17
Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
  • Hi, thanks at first. Can you give more detail about the information you gave above? In other words, I'd like to know which approach enables you navigate the results through the memory, scrollableResults or first/maxResult? The last wonder of mine is how to use fetchSize in action, do you have any link or code that should help me figure out that? Thanks.. – javatar Mar 05 '12 at 21:57