RMySQL result set is not "complete" after all results have been received

In a script that processes a lot of rows on a MySQL server, I use dbSendQueryit fetchto throttle fetch and process the results.

When my team fetchgets exactly the number of available rows (or to the left) in the result set, leaving 0 rows for selection, it dbHasCompletedreturns FALSE, whereas I expected it to return TRUE.

query <- "select record_id, name 
          from big_table left join another_table using (record_id) 
          limit 500"

resultset <- dbSendQuery(con, query)   # con: DB connection

while(!dbHasCompleted(resultset)) {
  input <- fetch(resultset, n = 500)
  print(paste("Rows fetched:", nrow(input)))
  # process input ...
}

I expected this loop to start once, but after execution there is an additional start, it printis called again:

Rows fetched: 500
...
Rows fetched: 0

-, dbHasCompleted(resultset) ( n = 1000, 2000, 3000). script n = 501 .

? - ?

+5

All Articles