Skip to content

Commit

Permalink
add more docs in the fetchSize doc
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Keao <[email protected]>
  • Loading branch information
YangKeao committed Aug 1, 2024
1 parent 31f298c commit 7a95b56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions best-practices/java-app-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Java 应用尽管可以选择在不同的框架中封装,但在最底层一般

TiDB 中同时支持两种方式,但更推荐使用第一种将 `FetchSize` 设置为 `Integer.MIN_VALUE` 的方式,比第二种功能实现更简单且执行效率更高。

对于第二种方法,TiDB 会先将所有数据加载到 TiDB 节点上,然后根据 `FetchSize` 依次返回给客户端。因此,通常会比第一种方法使用更多的内存,如果 [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom)`ON` 时,可能会将数据存储到临时磁盘中。

如果系统变量 [`tidb_enable_lazy_cursor_fetch`](/system-variables.md#tidb_enable_lazy_cursor_fetch)`ON`,TiDB 将尝试仅在客户端获取数据时提取,以使用更少的内存。有关详细信息和限制,请阅读变量 [`tidb_enable_lazy_cursor_fetch`](/system-variables.md#tidb_enable_lazy_cursor_fetch) 的描述。

### MySQL JDBC 参数

JDBC 实现通常通过 JDBC URL 参数的形式来提供实现相关的配置。这里以 MySQL 官方的 Connector/J 来介绍[参数配置](https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html)(如果使用的是 MariaDB,可以参考 [MariaDB 的类似配置](https://mariadb.com/kb/en/library/about-mariadb-connector-j/#optional-url-parameters))。因为配置项较多,这里主要关注几个可能影响到性能的参数。
Expand Down
4 changes: 4 additions & 0 deletions develop/dev-guide-connection-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ Java 应用尽管可以选择在不同的框架中封装,但在最底层一般

TiDB 中同时支持两种方式,但更推荐使用第一种将 **FetchSize** 设置为 `Integer.MIN_VALUE` 的方式,比第二种功能实现更简单且执行效率更高。

对于第二种方法,TiDB 会先将所有数据加载到 TiDB 节点上,然后根据 `FetchSize` 依次返回给客户端。因此,通常会比第一种方法使用更多的内存,如果 [`tidb_enable_tmp_storage_on_oom`](/system-variables.md#tidb_enable_tmp_storage_on_oom)`ON` 时,可能会将数据存储到临时磁盘中。

如果系统变量 [`tidb_enable_lazy_cursor_fetch`](/system-variables.md#tidb_enable_lazy_cursor_fetch)`ON`,TiDB 将尝试仅在客户端获取数据时提取,以使用更少的内存。有关详细信息和限制,请阅读变量 [`tidb_enable_lazy_cursor_fetch`](/system-variables.md#tidb_enable_lazy_cursor_fetch) 的描述。

### MySQL JDBC 参数

JDBC 实现通常通过 JDBC URL 参数的形式来提供实现相关的配置。这里以 MySQL 官方的 Connector/J 来介绍[参数配置](https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html)(如果使用的是 MariaDB,可以参考 [MariaDB 的类似配置](https://mariadb.com/kb/en/library/about-mariadb-connector-j/#optional-url-parameters))。因为配置项较多,这里主要关注几个可能影响到性能的参数。
Expand Down

0 comments on commit 7a95b56

Please sign in to comment.