4
I am building an app that will receive data from various different ERP’s every day.
But I have the following problem, the next day the ERP can send me the same data that had or did not changes + some new data. And I need to enter these new data and update the rest in case there is any change, and delete the old data that will no longer be used.
There are about 15 thousand records per day of each company, and I intend that this application is used by +- about 200 companies in media.
When I think about it, when I receive this information daily, I’d better go checking one by one to see if there were any changes and if so update them( select + update ).
Or every day I delete all information and enter again ( delete + Insert ).
What’s the fastest way to handle big information every day? If someone has similar experience and knows a different solution, I am also interested.
Thank you!
I think the most appropriate thing is to implement both alternatives and test performance. It may be that one solution is more suitable in one situation but not in another.
– Thiago Barcala
Are these +- 15,000 records all received at any given time or will this occur throughout the day? Will the system be accessible during the update? Can the update take place outside office hours? In my experience the 15 thousand records are not a problem to be considered, but the size of the database you will update and your expectation of growth of this database yes! I think you could explain in more detail the context of your problem so that it is possible to offer a response/suggestion.
– Caiuby Freitas
Instead of doing a select for later update, use the method ON DUPLICATE KEY UPDATE wouldn’t it be better?? I think I should take a performance test first, but I believe I would gain more speed without having to select. Because that way he would always try to insert new records, and would update only those that already exist in the database. Take a look: https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html.
– Fernando VR
I am also making a system like this and I would like to know which is the most efficient for tomorrow not to have problems, I have seen that delete can have a high cost for indexed tables, I was thinking about putting an N/C Normal and Canceled Record flag and updating the whole table instead of deleting, but then I fell for two other questions, is Update faster, and the swelling in the tables, by keeping unused records, did not affect select? I thought of this solution taking into account that there are tables with millions of records and the performance is good.
– Marcelo
Use the
INSERT ... ON DUPLICATE KEY UPDATE
who does this work for you.– Jorge B.