Is there a clear and more efficient replacement than a loop that checks all records?
I have a C # list that is populating from a database. So far its only 1400 records, but I expect it to grow LOT .. Usually I do validation for new data across the whole list .. What I am trying to figure out is is it faster to just clear the list and reload all data from the table, or will it check each entry is faster.
Intuition tells me that the dump and load method will be faster, but I decided to check first ...
a source to share
If my understanding is correct, you still have to load the list from MySql and it is very important that the list in memory is updated, right? So the only problem you are talking about is the dummy in the list memory.
Well, normally I would try to profile the different behaviors first, see what works best.
But as you state, I think that being clear and recreated should be faster than systematic checking and updating.
a source to share
Add the "InsertedTime" column to your database. Update these lines periodically with InsertedTime> ListCreatedTime (variable in your application)
This assumes the db data is not being deleted
If you want to handle db changes like update and delete. You can better set flags in your db. Later, when you have updated your list, you can delete your entries from your application.
But anyway project your dump and load method and compare it to this to see which is faster in your scenario.
a source to share