search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Page is too slow when loading using Session DataTable

Asked by rul
17 years ago.

I'm building a calendar app using your plugin, but it is too slow when loading on the live server. on my local development though, i don't feel a thing. everything is super fast there.

In my code below, I bind the calendar to the calendar object only ONCE in the Page_Load handler. This is the only time all the data from the mysql database is loaded onto the DataTable object.

Everytime an item is selected, the page is reloaded, and if Page is a PostBack it doesnt bind the data to the session datatable. So theoretically, it should behave more faster right? How do I solve this performance issue??

System.Data.DataTable BuildCal (string qcal) {
// Create a DataSet
System.Data.DataSet ds = new System.Data.DataSet();
// Create a DataTable to hold results
System.Data.DataTable dt = new System.Data.DataTable("calendar");
// Add the table to the dataset
ds.Tables.Add(dt);

//Create Columns for data
dt.Columns.Add(new System.Data.DataColumn("event_id", typeof(Int32)));
dt.Columns.Add(new System.Data.DataColumn("cal_id", typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("posted_by", typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("date_posted", typeof(DateTime)));
dt.Columns.Add(new System.Data.DataColumn("title", typeof(String)));
dt.Columns.Add(new System.Data.DataColumn("description", typeof(String)));
dt.Columns.Add(new System.Data.DataColumn("location", typeof(String)));
dt.Columns.Add(new System.Data.DataColumn("start_time", typeof(DateTime)));
dt.Columns.Add(new System.Data.DataColumn("end_time", typeof(DateTime)));
dt.Columns.Add(new System.Data.DataColumn("coy_id", typeof(Int32)));

if (qcal == "") {
qcal = "SELECT event_id, cal_id, posted_by, ADDTIME(date_posted, '" + Session["GMT"] + ":00') as date_posted, title, description, location, ADDTIME(start_time, '" + Session["GMT"] + ":00') as start_time, ADDTIME(end_time, '" + Session["GMT"] + ":00') as end_time, coy_id FROM matadorsystem.mtd_calendar";
}

/* Checks the state of the connection and closes it if it is open */
if(dbConnection.State == System.Data.ConnectionState.Closed) {
dbConnection.Open();
}

OdbcDataAdapter dataAdapter = new OdbcDataAdapter(qcal, dbConnection);
dataAdapter.Fill(dt);

return dt;
}

protected void BindIndex(int vnd) {
DateTime nowDate;

string qcal="";

Session["dt"] = BuildCal(qcal);

DayPilotCalendarWeek.DataSource = Session["dt"];

DayPilotCalendarWeek.BeginColumnName = "start_time";
DayPilotCalendarWeek.EndColumnName = "end_time";
DayPilotCalendarWeek.NameColumnName = "title";
DayPilotCalendarWeek.PkColumnName = "event_id";

DayPilotCalendarWeek.DataBind();


DayPilotCalendarDay.DataSource = Session["dt"];

DayPilotCalendarDay.BeginColumnName = "start_time";
DayPilotCalendarDay.EndColumnName = "end_time";
DayPilotCalendarDay.NameColumnName = "title";
DayPilotCalendarDay.PkColumnName = "event_id";

DayPilotCalendarDay.DataBind();

//Response.Write(viewmode);

Session["viewmode"] = viewmode;


if (vnd==0 && viewmode != "month" && Session["currday"] == ""){
//Response.Write(Session["currday"]);
nowDate = nowDateUtc.AddHours(Convert.ToDouble(Session["GMT"]));
} else if (vnd == 0 && viewmode!= "month" && Session["currday"] != "") {
//Response.Write(lblTitle.Text);
//Response.Write(Session["currday"]);
nowDate = Convert.ToDateTime((CurrDayShown.Value)).AddDays(0);
} else if (vnd!=0 && viewmode != "month") {
nowDate = Convert.ToDateTime((CurrDayShown.Value)).AddDays(vnd);
} else if (viewmode == "month" && Session["currday"] != "") {
nowDate = Convert.ToDateTime((CurrDayShown.Value)).AddMonths(vnd);
CalendarMain.VisibleDate = nowDate;
} else if (viewmode == "month" && Session["currday"] == "") {
nowDate = nowDateUtc.AddHours(Convert.ToDouble(Session["GMT"]));
CalendarMain.VisibleDate = nowDate;
} else {
nowDate = nowDateUtc.AddHours(Convert.ToDouble(Session["GMT"]));
CalendarMain.VisibleDate = nowDate;
}

//Response.Write(vnd);

int dow = Convert.ToInt32(nowDate.DayOfWeek);
int sDateInt = 0;

if (dow != 0) {
sDateInt= -dow;
}

DateTime sDate = nowDate.AddDays(sDateInt);
DateTime eDate = sDate.AddDays(6);

if (viewmode=="week") {
sDate = nowDate.AddDays(sDateInt);
eDate = sDate.AddDays(6);

DayPilotCalendarWeek.StartDate = sDate;
DayPilotCalendarWeek.EndDate = eDate;

lblTitle.Text = sDate.ToString("dd MMM, yyyy") + " to " + eDate.ToString("dd MMM, yyyy");
CurrDayShown.Value = Convert.ToString(nowDate);
}

if (viewmode=="day") {
sDate = nowDate;

DayPilotCalendarDay.StartDate = sDate;
DayPilotCalendarDay.EndDate = sDate;

lblTitle.Text = sDate.ToString("dd MMM, yyyy");
CurrDayShown.Value = sDate.ToString();
}

if (viewmode=="month") {
sDate = nowDate;

lblTitle.Text = sDate.ToString("MMMM yyyy");
CurrDayShown.Value = sDate.ToString();
}

if (viewmode=="agenda") {
sDate = nowDate;

lblTitle.Text = sDate.ToString("dd MMM, yyyy");
CurrDayShown.Value = sDate.ToString();
drawAgenda();
}

}
Comment posted by Dan Letecky
17 years ago.
All the data that you supply using DataSource property are stored in ViewState. If you are loading a lot of events using your SQL command (not just the events that are visible) the ViewState grows incredibly. Then the page renders slowly (it has to save all the events in ViewState) and the PostBacks are even slower (because it is sending all the data to the server again).

Check the following:
  • Test how many events your SELECT command returns.
  • Open the source of the rendered page to see how big the __VIEWSTATE hiden input field is.
If it's really the ViewState what's slowing you down I suggest the following:
  • Limit the number of events you are loading from database by adding WHERE clause to your SELECT command. Generally, you don't have to be afraid so much of reloading data from a database (any good DB system will cache it for you).
If it's not the problem send me the source of the rendered page so I can take a look at it.
Comment posted by Anonymous
14 years ago.

I have the same problem, the page is too slow even in the development environment.

I have an Ajax Toolkit Tab container that has 4 tabs(Today,Day,Week and Month)

every tab has a day pilot scheduler view.

when i viewed the source of the generated HTML i found that it has the styles written to the tags instead of defiend in css

when i saved the html it was 2 MB size which is huge for the browser to render.

note that i only set the sources to about 20 source and i didn't even bind to the events yet.

do you have a solution for that?

Comment posted by Dan Letecky
14 years ago.

It looks like you are using the Scheduler from the Lite edition which renders all the HTML on the server side.

The recommended solution would of course be to switch to the Scheduler from the Pro edition (download an feature-unlimited trial version). The performance of the Pro version is far superior:

  • It generates the DOM structure on the client side. No style definition sent for each element individually.
  • Rendering of hidden areas (background cells and events) is deferred (dynamic rendering). It's rendered when the user moves the scrollbar.
  • The 5.8 release will introduce a dynamic loading feature (events and background cells are loaded from the server and rendered when the user moves the scrollbar) which is already implemented in the Dynamic Scheduler.
Comment posted by Ayaz Ahmad
13 years ago.

Hi,

I am also using your DayPilot Pro control to build a scheduler. In my case i have more than 750 resources and few events. But your control is very slow to render resources. is 750 too much? Shuld i limit my resources?

Also, sometimes it raises error ofmax request length exceeded. I am using IIS 7 and it is very slow, even not usable. please assist how to improve its speed.

Comment posted by Dan Letecky
13 years ago.

750 resources is quite a lot. The serialized resources list is sent back and forth with every request. I would suggest breaking the resources into groups using the resources tree feature and delay the children loading using Resource.ChildrenLoaded = false and LoadNode event. That is dynamic tree loading as demonstrated here:

www.daypilot.org/demo/Scheduler/DynamicTreeLoading.aspx

Comment posted by Ayaz Ahmad
13 years ago.

I have 8-9 flag/attributes sittingin Tag collection of event. Is it fine? Do i need to limit them too?

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.