Is there a mysql JDBC that will respect fetchSize?

后端 未结 3 943
太阳男子
太阳男子 2020-12-15 06:38

I am using MySQL and want to utilize the setFetchSize property. The default MySQL JDBC implementation does not really respect it. If you set fetchsize to

3条回答
  •  心在旅途
    2020-12-15 07:10

    If you enable the MySQL JDBC option useCursorFetch, fetchSize will indeed be respected by the driver.

    However, there is one disadvantage to this approach: It will use server-side cursors, which in MySQL are implemented using temporary tables. This will mean that results will not arrive until the query has been completed on the server, and that additional memory will be used server-side.

    If you just want to use result streaming and don't care about the exact fetch size, the overhead of setFetchSize(Integer.MIN_VALUE) is not as bad as the docs might imply. It actually just disables client-side caching of the entire response and gives you responses as they arrive; there is no round-trip per row required.

提交回复
热议问题