Skip to content

concurrent reading/writing in "chunks" with RSQLite (need some help troubleshooting)

1 message · kMan

#
Hi Seth,

This particular list requires considerable stretching on my part, so I would not be surprised if I missed a goal implied by the code style used or off-list correspondence.

If I understood the original code correctly, though, each iteration through the loop required (2) queries, a read and a write, where (I've assumed) the result sets are handled one at a time anyway. The code I proposed does the same thing, but overall there is (1) additional query prior to the loop to get the number of rows. The rest is just case processing b/c dbGetQuery() seemed to do funny things when LIMIT extended beyond the end of the table, and it wouldn't remember its last read location (e.g. didn't work like scan()). In addition, it works with dbWriteTable() and gets around the need for creating the table first, and filling it in later. 

I used the WHERE condition for lack of a better way to seek to a particular record. The fetch() & fetch_n, were those intended to get the read queries to start at the last read location (e.g. like serial reads using scan())? Eliminating need to condition match or generate a db index first would speed things up, and I'd very much like to learn that trick. I'd think it would also make for an excellent R-wiki post. 

Sincerely,
KeithC.

-----Original Message-----
From: Seth Falcon [mailto:seth at userprimary.net] 
Sent: Tuesday, June 29, 2010 9:37 PM
To: kMan
Cc: Jonathan Greenberg; r-sig-db at stat.math.ethz.ch
Subject: Re: R-sig-DB Digest, Vol 68, Issue 7
On Tue, Jun 29, 2010 at 8:19 PM, kMan <kchamberln at gmail.com> wrote:
While it is true that you can read and write from a single connection,
you can only have one result set open at a time and so if you want to
iterate through a result set and then write, you do, I believe, need
two connections.


I suspect that the code you propose will be considerably slower as you
are issuing multiple queries along with a WHERE constraint.

+ seth