Squeezing Performance from SQLite: Insertions (with Room)
Jason Feinstein
2423

I think you should also benchmark iterating on items yourself and inserting them one by one inside your own transaction:

roomDatabase.beginTransaction();
try {
for (MyItem item : itemIterable) {
myDao.insert(item);
}
roomDatabase.setTransactionSuccessful();
}
finally {
roomDatabase.endTransaction();
}

This avoids the high memory usage issue you mentioned and if the performance is good enough, Room doesn’t even need built-in support for Iterables.

Like what you read? Give Christophe Beyls a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.