'Flutter sqlite fast data save and update

I have a table with 19,000 rows, I want to sync it with remote server (mysql). If the data retrieved from the remote server is on sqlite, I want it to update the data, but add new data if there is no data, but this process is very slow and takes long minutes. What is the fastest way to do this?

What I've tried: "await delete data" - "await add data" - Slow

"await check for data" - "update if data exists or add new" Slow

"delete data, add after deletion" It's fast but inaccurate, when I use this method, the database crashes and I can't take action.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source