On Mon, 2017-04-10 at 21:39 +0100, Simon Slavin wrote: > On 10 Apr 2017, at 9:28pm, Reid Thompson <reid.thomp...@ateb.com> wrote: > > > my questions are, if I prepare and utilize a statement for a result set > > in the tens of thousands (or more) using a where clause along the lines > > of > > "ORDER BY batch_id, due_datetime, random()" > > > > 1) As I sqlite3_step through the result set, am I guaranteed to get each > > row only once? > > Yes. _step() will return each row exactly once. This assumes you will not > make any changes to the table those rows are in until you have finished > stepping. If you make any changes to the table > before the last call to _step() then things may get more complicated.
Thank you Simon. so things may get more complicated: Does 'more complicated' in the below scenario mean that there is potential for records to be returned more than once if I use random()? I have a manager process that manages the above step'ing. It gathers records in batches of 30, marks them as claimed, and forwards those batches to one of 50 worker processes. Each worker process performs work based on each records data and when complete provides that information back to the manager along with the record data. The manager process uses the returned information to update the records. When a worker completes a batche, the manager process sends them another batch. So in most cases, I'm performing two updates to the record while step'ing through the result set. > > 2) is the order set only once on the first sqlite3_step, or does it > > change with each sqlite3_step invocation? > > Because no index already exists for that ORDER, you can imagine that SQLite > makes up a temporary index for the results when you do the first > sqlite3_step(), and deletes it when you execute > sqlite3_reset() or sqlite3_finalize(). > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users