Synchronizing sqlite database from memory to file

后端 未结 3 1798
梦如初夏
梦如初夏 2020-12-31 18:21

I\'m writing an application which must log information pretty frequently, say, twice in a second. I wish to save the information to an sqlite database, however I don\'t mind

3条回答
  •  长情又很酷
    2020-12-31 18:55

    If you're executing each insert within it's own transaction - that could be a significant contributor to the slow-downs you're seeing. Perhaps you could:

    • Count the number of records inserted so far
    • Begin a transaction
    • Insert your record
    • Increment count
    • Commit/end transaction when N records have been inserted
    • Repeat

    The downside is that if the system crashes during that period you risk loosing the un-committed records (but if you were willing to use an in-memory database, than it sounds like you're OK with that risk).

提交回复
热议问题