Hi everybody, I have a user control that fetches data from a database. It takes a lot of time. Also the speed of my web application has become slow. What should I do to make page loading faster?
I will answer in general way.
If you only fetches data with out calculations, then:
DataBase Part
a. Optimize your sql query, be sure that you use the right indexes on database.
b. Do not load more than the data that you won to show, and do paging.
c. If you fetch data from too many tables at the same time, create a new 'flat' table, and pre render your results there on a scheduled regular base on a background thread.Page Part
a. While you load data, show them imidiatle and do not buffer them, and time to time make a flush to the responce.If you fetche data with calculations, then make the calculations on a background thread before you show them on a scheduled base, place them on one other flat table, and show that table.
For example, how to show the data while you get them....
<%
int KathePoteFlush = 1;
object Data;
While(GetNextData(Data))
{
if (20 % KathePoteFlush++ == 0)
Response.Flush();
Response.Write(RenderMyTableData(....data....));
};
%>