I have the following
public class SearchResult
{
public string Description { get; set; }
public int Year{ get; set; }
public int Type { get; set; }
}
I create a list of these List and cache it then I try to search through this collection (1.2M) records with following
var found = myList.Where(x => x.Description.StartsWith(query)).Take(10).ToList();
This is pretty slow what I am going for, is there a better way to store a list of objects and have the ability to search the string property of the object?
Should I be sorting the collection before caching it? I would like to have the ability to do .StartsWith and .Contains on Description property with the fastest path to get top 10 matches.
If i just go to the db its faster (i have put a index on the text field), I am hoping to improve my performance by getting the results once, sticking them in memory and then all searches are done against the cache in memory vs going to the db each time. But this is proving to be slower then the db calls using the SQL LIKE '{query}%' statement