Home > database > Insert a interval if use transaction
Insert a interval if use transaction
Time:09-20
hello, I'm not too skilled, database now would like to ask you a question, there is a project that continues to receive data, but the received data is clearance, such as 500 milliseconds, 50 milliseconds or less, in short interval, but has been receiving, and each was a great amount of data that are (which may be a few M), I need to receive the data stored in database, in order to achieve high performance, should use the way of transaction, one-time insert multiple data, rather than one at a insert, but I have a question, with space between each of the data, can use transaction, how do you use? How long come to a unified insert, and, if there is wrong, that data gathered in front of me, haven't had time to insert, also submit an expense account, how to reduce the loss, I don't want to because of the failure of a data let front have received didn't save the data, this to want how to solve, I is very less for database experience, also hope that we speak a lot, a lot of help, thank you! Also hope to have the friend of experience can use the code examples, I was developed by using VC2015,
CodePudding user response:
Receive data, write caching, record a batch ID at the same time, to achieve a certain amount, batch write database, write the database successfully, clear the cache, failures are rolled back things, according to the batch ID retry,