Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 10, 2012 12:12 PM by KenParkerJr
May 10, 2012 08:06 AM|LINK
My Stored Procedure returns data of the following SQL:
select distinct firstname from Emp
select distinct lastname from Emp
select distinct preferrred from Emp
select distinct othername from Emp
DataReader has four resultsets, each resultset needs to be stored in a separate list without iterating each record in each resultset as this impacts application performance.
May 10, 2012 12:12 PM|LINK
DataReader is the simplist way to communicate with the database. Other componenets like DataAdapter use DataReader to put the data into the right format. You are going to have to itterate over the data if you want it in a list. There are a few things that
you can do about the performance hit.
1. If you are converting it to a list of classes try using structs to store the data instead. Structs are a little bit lighter.
2. Find a way to reduce your result set. This is a fundamental design decision. If you want responsive applicaitons find a way to reduce the data being returned by selecting only records that you need. Most users can not sift thru 100K records so why are
you giving it to them?Can you narrow it down by date, Age, status?
3. Always get real numbers do not assume that something is the bottleneck when you dont have proof. You need to be able to record what the time it took to loop thru and create a list of class instances vs what time it would take to loop thru and get a List
of structs for example.
4. If you are hitting a db then it makes a big diffrence where the db is located. Hitting your test server can be much slower then hitting your local machine or hitting production. Network issues can cause performance hits.