0

I have asked this question ever before and it seems I didn't 100% resolved it. Please see link A search aspx page return slow, I disable the IIS logs, but it seems still load slowly.

I have a asp.net website, there is a searchResult.aspx, it runs a sql script to retrieve data from MS SQL server database, and then put the data into a HTML format, the website has been deployed in IIS7.5 Server. I have implemented both static and dynamic compression, that means all my js, css and aspx page have been compressed before rendered to browser.

Unfortunately the searchResult.aspx return very slow, if search for a big word, like biography, it averagely takes more than 10 seconds to return. and I used firebug Net to trace it, the blocking, DNS Lookup, Connecting and Sending all take no more than 10ms, but the Waiting takes over 10 seconds. So I added some code to the beginning and end of function Page_Load(object sender, EventArgs e) and also the begining and end of HTML body element, like below:

protected Stopwatch stopwatch = new Stopwatch();
protected void Page_Load(object sender, EventArgs e)
 {
     stopwatch.Start();
     ....
     stopwatch.Stop();
     timeForSearch = stopwatch.Elapsed.Milliseconds;
  }


   <body>
    <%
     stopwatch.Reset();
     stopwatch.Start();
    %>
    ....
   <%stopwatch.Stop();%>
  <%=timeForSearch%>+<%=stopwatch.Elapsed.Milliseconds%>=       <%=stopwatch.Elapsed.Milliseconds + timeForSearch%>

enter image description here

OK, you can see the pic, the highlight is the millinseconds elapsed, but why it took 4.8 seconds to load.

Any help will be appreciated.

Community
  • 1
  • 1
danmiao
  • 747
  • 2
  • 8
  • 17
  • 1
    Are you really sure that this slowness is not related to your data access logic? – mamoo Mar 27 '12 at 06:12
  • Show the SQL query that is used. Also are you using gridview or other data control? – PraveenVenu Mar 27 '12 at 06:17
  • Use SQL Server Profiler? – IrishChieftain Mar 27 '12 at 13:40
  • Hi mamoo, as I show, you can see, I used a stopwatch to calculate the time the whole Page_Load() function consumed, it is just several hundreds millinseconds, and I also debug it in my dev environment, it is fast, so I think I can confirm the time-spend of sql process. – danmiao Mar 27 '12 at 23:40

1 Answers1

1

Ok, I thought I found out the reason why the search page load slowly, just all of your concerns, it is because of SQL script, the reason why I didn't notice it is because the code error, I used the

stopwatch.Elapsed.Milliseconds

Actually I should use

stopwatch.ElapsedMilliseconds

The difference between them are in Difference between ElapsedTicks, ElapsedMilliseconds, Elapsed.Milliseconds and Elapsed.TotalMilliseconds? (C#). And it finally shows me that my Page_Load() method takes sometimes more than 5, or 7 seconds to load according to the search term.

So I will need to improve the sql script, cause it is very big, so I will not write down it. Anyway thanks all you guys, I was inspired by your concerns.

Community
  • 1
  • 1
danmiao
  • 747
  • 2
  • 8
  • 17