gpt4 book ai didi

java - MySQL 和 Java : Difference between fetch size and batch limit

转载 作者:行者123 更新时间:2023-11-29 12:43:29 30 4
gpt4 key购买 nike

当我修改使用Java对MySQL检索进行批量更新的代码时,我产生了这个疑问。我的理解是,获取大小是 ResultSet 对象中的最大行数,批处理限制是可以添加到批处理中以进行批处理执行的选择/插入/更新查询的数量。如果我错了,有人可以纠正我吗?

谢谢。

最佳答案

你几乎是正确的。但是要添加到它 javadoc of Statement#setFetchSize()

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database

而批量限制与您可以插入或更新与 max_allowed_packet 相关的行数有关。

附注:

您还可以查看 JDBC API implementation notes作为一本好书

ResultSet

By default, ResultSets are completely retrieved and stored in memory. In most cases this is the most efficient way to operate, and due to the design of the MySQL network protocol is easier to implement. If you are working with ResultSets that have a large number of rows or large values, and cannot allocate heap space in your JVM for the memory required, you can tell the driver to stream the results back one row at a time.

关于java - MySQL 和 Java : Difference between fetch size and batch limit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25784252/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com