0

An operation on my android app's table takes place in batches of N rows. I have a field batch_id in my table which indicates the batch that row belongs to (the first N rows have X as it's batch_id, the next N has Y and so on). The operation on a batch might end up either as a success or a failure. Depending on the result of the operation, I will update the status of the rows with that batch_id.

Assuming that the batch_id field is initially empty for all entries, how do I efficiently do batching of N rows on an android table?

not_again_stackoverflow
  • 1,285
  • 1
  • 13
  • 27

1 Answers1

1
  1. Select the first N rows that don't have a batch id
  2. Update the batch id to x
  3. Increment x
  4. Repeat until no more rows are found

If that's too slow there's probably some tricky sql statement you could use. But do some testing before you bother with that because you won't know if it's too slow until you try it.

nasch
  • 5,330
  • 6
  • 31
  • 52