I am planning a web service (.NET asmx) which I need to optimize as much as possible.
The web service returns 10 random records (each call from a client needs to be random) from the database (Mysql) according to a parameter passed from the client. Each paramter (1-12) holds ~2000 records in the DB.
solutions:
- Querying the DB (which will be indexed by the parameter) and just return the result.
- Cache the table from the DB to a .net Datatable and select by Linq (~15,000 records).
- Cache the DB into 12 .net DataTables, each for possible param, and query the Datatable
with Linq.
What is the best way to preform this task? I would love to hear other ideas!
Best Regards, Udi
Cache the data into 12 strongly-typed arrays. That removes all processing besides selecting 10 random records from a simple array. It doesn’t get faster than that.
Don’t use data tables. Why would you? They can only be slower than strongly typed lists/arrays of a custom class.
How to optimize selecting 10 random items is a different question, though, that surely has been answered already.