I have a refresh function. Which will have to compare each row of given data to the database. If it does not exist, insert the new data, else skip it.
But i was wondering, will it be much more efficient i rebuild the whole table of data? Instead of comparing it row by row, i just delete the whole table and insert all the data again?
Which is much more efficient?
For big changes rebuilding the table can be most efficient. But only if you are using truncate table. A “delete from x” without where is likely to be even slower.
The only way to find out where the tipping point is is to measure.
You can only truncate a table if it is not referenced by foreign keys. So you might have to delete/disable the before truncating the table.