Jack
Jack

Reputation: 5870

What's the default server side fetch number by Mysql

If I used MySQLdb or JDBC to issue the sql: select * from users to Mysql. Suppose the table has 1 billion records. Then how many rows would be returned by Mysql in one chunk/package. I mean Mysql won't transfer the rows one by one neither transfer all of the data just one time, right? So what's the default chunk/package size one internet transfer to the client please?

If I used server-side cursor then I should set the fetch size bigger than default chunk size for better performance, right please?

Upvotes: 1

Views: 127

Answers (1)

MikeVe
MikeVe

Reputation: 1120

The implementation notes of MySQL's JDBC API implementation points out, that by default the whole set will be retreived and stored in memory. So if there are 1 billion records they will be retreived. The limiting factor would probably be the memory of your machine.

So to sum up the size of the ResultSet retreived is depending on the JDBC implementation. For example Oracle's JDBC-Driver would only retreive 10 rows at a time and store them in memory.

Upvotes: 2

Related Questions