With SQLDelight is there any way for a bulk insert...
# squarelibraries
w
With SQLDelight is there any way for a bulk insert beyond a for loop in a transaction? I'm doing this
Copy code
messageDao.transaction {
    newMessages
        .map { it.toDbMessage(groupId) }
        .forEach(messageDao::insertOrIgnore)
}
and with about 1000 messages its taking 200-300 ms (on an emulator). i imagine a real device might be slightly faster but not an order of magnitude faster. Is there anything else I can do to speed this up? table details in thread
Table:
Copy code
CREATE TABLE Message (
  groupId INTEGER NOT NULL,
  messageId INTEGER NOT NULL,
  sender TEXT NOT NULL,
  message TEXT NOT NULL,
  timestamp TEXT NOT NULL,
  PRIMARY KEY (groupId, messageId)
);
`insertOrIgnore`:
Copy code
insertOrIgnore:
INSERT OR IGNORE INTO Message
    VALUES ?;
l
Not really, afaik. But you’re doing it right by wrapping in a transaction
896 Views