views:

32

answers:

2

Actually i want to generate a list of applicants (more than 1000) on a view for that i am using sql data reader and genrting a List and passing to Views but it is taking big time(4 to 5 second) to show on View when records are more than 500 is this normal .

{

public static ApplicantsList GetListSend(string category, string subDiv) { string os = "N"; if (category == "SCOS") os = "Y"; Applicant App;//Applicant Class Contains Name,Address,Phone etc//// ApplicantsList AppList = new ApplicantsList();//ApplicantLst Class List type// string sqlcon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString(); SqlConnection con = new SqlConnection(sqlcon); con.Open(); string SqlQuery = "SELECT [idno], [ApplicantName], [Address], [Status], convert(varchar(10), DateOfApplication,103) as DateOfApplication FROM [SCOBC] where (status = 'Pending With Dealing Assistant' and category='" + category + "') and SubDiv ='" + subDiv + "' and os ='" + os + "' order by idno"; SqlCommand cmd = new SqlCommand(SqlQuery, con); SqlDataReader sdr = null; sdr = cmd.ExecuteReader(); if (sdr.HasRows) { while (sdr.Read()) { App = new Applicant(); App.IdNo = sdr["idno"].ToString(); App.Name = sdr["ApplicantName"].ToString(); App.Address = sdr["Address"].ToString(); App.Status = sdr["Status"].ToString(); App.DateOfApp = sdr["DateOfApplication"].ToString(); AppList.Add(App);

            }
            sdr.Close();
            con.Close();
        }
        return AppList;
    }

}

+2  A: 

I don't know if it is normal that your database call takes 4-5s but what is not normal is showing a list of 1000 items on a single view without implementing paging.

When you implement paging not only you will make your page smaller and easier to read from the users but will greatly improve performance as you will be fetching only what's needed. Of course in order for this to be effective the paging must be done on the SQL Server.

Darin Dimitrov
ok thanks but question is not about use paging
is it ok to first generate a list(loop) and then genrate view (again using loop)?
Well then you will need to optimize your SQL queries so that they take less time to execute. If they cannot be optimized you will need to purchase faster hardware, upgrade bandwidth, etc... Don't expect miracles.
Darin Dimitrov
A: 

It is not unusual to see a page with so much data take a long time to render. The next step is to determine which part of the pages life cycle is taking up so much time. It could be the SQL call, the rendering of the HTML, or something else but you really need to limit the scope of the problem to effectively plan how you are going to fix it. I have seen it where the SQL query is really fast but with tons of data the HTML page is so large that it takes the web browser forever to render it.

Blegger