mysql - DBI/RMySQL/RMariaDB 中 dbClearResult() 的用途是什么?

标签 mysql r rmysql r-dbi

这里是SQL新手。在Hello World section of the RMySQL github page , 有以下 -

# You can fetch all results:
res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
dbFetch(res)
dbClearResult(res)

我不明白 dbClearResult() 的用途。这对我很重要,因为我正在处理几个大表,dbClearResult(rs) 有时可能非常慢(需要几分钟才能完成)。但是,如果我进入 mysql shell,我可以立即终止查询。

那么,dbClearResult() 的目的是什么,有什么办法可以避免或加快速度吗?

最佳答案

来自DBI documentation对于 dbClearResult:

Frees all resources (local and remote) associated with a result set. In some cases (e.g., very large result sets) this can be a critical step to avoid exhausting resources (memory, file descriptors, etc.)

关于mysql - DBI/RMySQL/RMariaDB 中 dbClearResult() 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51657701/

相关文章:

MySQL 触发器通过重新排序其值来更新列

r - 显示 ggplot2 标题而不为其保留空间

r - R 中的forceNetwork 让人疯狂 : no edges displayed

linux - R 版本 2.15 MySQL 连接 Windows 和 Centos

mysql - 用 RMySQL 写日期

php - 防止重复数据进入mysql数据库

mysql - Yii2 多表查询

java - 无法在 java 中使用 executeQuery 发出数据操作语句

r - 将不同长度的向量组合成R中的数据框

mysql - SQL:使用 NA 查询分组依据和条件