Looks like a database call obsession to me…
-
protected void LiveList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField username = (HiddenField)e.Item.FindControl("hidden_username");
Image mapbtn = (Image)e.Item.FindControl("mapbtn");
System.Web.UI.HtmlControls.HtmlTableRow tr = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("rowlive");if (mapbtn != null && username != null) { UserProfile selectedUser = null; selectedUser = Sql.GetUserDetails(username.Value); if (selectedUser != null) { BroadcastOptions broadcastOptions = BroadcastOptions.None; int sessionId = 0; if (Sql.CheckActiveSession(selectedUser.UserId, Visibility.IncludePrivate, out sessionId, out broadcastOptions)) { Location\[\] locs = Sql.GetLocationByVodID(sessionId); if (locs.Length > 0) { String mapUrl = mViewWebSite.AbsolutePath( String.Format("/map.aspx?live=true&target\_id={0}&uid={1}", sessionId, selectedUser.UserId.ToString())); mapbtn.Enabled = true; mapbtn.ImageUrl = "Images/miniWorldMap.png"; mapbtn.Attributes.Add("style", "Cursor:Pointer"); mapbtn.Attributes.Add("onclick", "ShowLocation('" + mapUrl + "')"); } } } }
}
The above code was written by our previous senior web developer (that's what told to me when I was hired). On every item bound on the repeater he 1) reads the username from hidden control :doh: 2) call database to load user details :| 3) another call to database to check any active sessions :omg: 4) another call to load whole list of gps locations to find whether gps is enables or not :doh: 5) then finally enable the map button if gps is enabled Amazingly this list is inside an update panel that updated every 10 seconds :(( :(( So for an average list of 30 users => total 3x30 = 90 database calls every 10 seconds when i traced the page it was hauling at 320 Kb every 10 sec. X| Fixed this in database, bringing a bool flag back by doing some joins and determining weather gps is enabled or not. Now only 1 db call every 10 sec.
-
protected void LiveList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField username = (HiddenField)e.Item.FindControl("hidden_username");
Image mapbtn = (Image)e.Item.FindControl("mapbtn");
System.Web.UI.HtmlControls.HtmlTableRow tr = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("rowlive");if (mapbtn != null && username != null) { UserProfile selectedUser = null; selectedUser = Sql.GetUserDetails(username.Value); if (selectedUser != null) { BroadcastOptions broadcastOptions = BroadcastOptions.None; int sessionId = 0; if (Sql.CheckActiveSession(selectedUser.UserId, Visibility.IncludePrivate, out sessionId, out broadcastOptions)) { Location\[\] locs = Sql.GetLocationByVodID(sessionId); if (locs.Length > 0) { String mapUrl = mViewWebSite.AbsolutePath( String.Format("/map.aspx?live=true&target\_id={0}&uid={1}", sessionId, selectedUser.UserId.ToString())); mapbtn.Enabled = true; mapbtn.ImageUrl = "Images/miniWorldMap.png"; mapbtn.Attributes.Add("style", "Cursor:Pointer"); mapbtn.Attributes.Add("onclick", "ShowLocation('" + mapUrl + "')"); } } } }
}
The above code was written by our previous senior web developer (that's what told to me when I was hired). On every item bound on the repeater he 1) reads the username from hidden control :doh: 2) call database to load user details :| 3) another call to database to check any active sessions :omg: 4) another call to load whole list of gps locations to find whether gps is enables or not :doh: 5) then finally enable the map button if gps is enabled Amazingly this list is inside an update panel that updated every 10 seconds :(( :(( So for an average list of 30 users => total 3x30 = 90 database calls every 10 seconds when i traced the page it was hauling at 320 Kb every 10 sec. X| Fixed this in database, bringing a bool flag back by doing some joins and determining weather gps is enabled or not. Now only 1 db call every 10 sec.
saxenaabhi6 wrote:
Looks like a database call obsession to me…
Come on, that's not obsession. That's the relationship between boys and their toys.
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
protected void LiveList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField username = (HiddenField)e.Item.FindControl("hidden_username");
Image mapbtn = (Image)e.Item.FindControl("mapbtn");
System.Web.UI.HtmlControls.HtmlTableRow tr = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("rowlive");if (mapbtn != null && username != null) { UserProfile selectedUser = null; selectedUser = Sql.GetUserDetails(username.Value); if (selectedUser != null) { BroadcastOptions broadcastOptions = BroadcastOptions.None; int sessionId = 0; if (Sql.CheckActiveSession(selectedUser.UserId, Visibility.IncludePrivate, out sessionId, out broadcastOptions)) { Location\[\] locs = Sql.GetLocationByVodID(sessionId); if (locs.Length > 0) { String mapUrl = mViewWebSite.AbsolutePath( String.Format("/map.aspx?live=true&target\_id={0}&uid={1}", sessionId, selectedUser.UserId.ToString())); mapbtn.Enabled = true; mapbtn.ImageUrl = "Images/miniWorldMap.png"; mapbtn.Attributes.Add("style", "Cursor:Pointer"); mapbtn.Attributes.Add("onclick", "ShowLocation('" + mapUrl + "')"); } } } }
}
The above code was written by our previous senior web developer (that's what told to me when I was hired). On every item bound on the repeater he 1) reads the username from hidden control :doh: 2) call database to load user details :| 3) another call to database to check any active sessions :omg: 4) another call to load whole list of gps locations to find whether gps is enables or not :doh: 5) then finally enable the map button if gps is enabled Amazingly this list is inside an update panel that updated every 10 seconds :(( :(( So for an average list of 30 users => total 3x30 = 90 database calls every 10 seconds when i traced the page it was hauling at 320 Kb every 10 sec. X| Fixed this in database, bringing a bool flag back by doing some joins and determining weather gps is enabled or not. Now only 1 db call every 10 sec.
-
saxenaabhi6 wrote:
senior web developer
... and now? retired? ;) Little bit of a question... was he willing to rethink what've done?
(yes|no|maybe)*
hehe i dont know... but i doubt my manager, he might have lied to me that they had a senior developer before, just to save reputation of the company ;P
-
hehe i dont know... but i doubt my manager, he might have lied to me that they had a senior developer before, just to save reputation of the company ;P
-
protected void LiveList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenField username = (HiddenField)e.Item.FindControl("hidden_username");
Image mapbtn = (Image)e.Item.FindControl("mapbtn");
System.Web.UI.HtmlControls.HtmlTableRow tr = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("rowlive");if (mapbtn != null && username != null) { UserProfile selectedUser = null; selectedUser = Sql.GetUserDetails(username.Value); if (selectedUser != null) { BroadcastOptions broadcastOptions = BroadcastOptions.None; int sessionId = 0; if (Sql.CheckActiveSession(selectedUser.UserId, Visibility.IncludePrivate, out sessionId, out broadcastOptions)) { Location\[\] locs = Sql.GetLocationByVodID(sessionId); if (locs.Length > 0) { String mapUrl = mViewWebSite.AbsolutePath( String.Format("/map.aspx?live=true&target\_id={0}&uid={1}", sessionId, selectedUser.UserId.ToString())); mapbtn.Enabled = true; mapbtn.ImageUrl = "Images/miniWorldMap.png"; mapbtn.Attributes.Add("style", "Cursor:Pointer"); mapbtn.Attributes.Add("onclick", "ShowLocation('" + mapUrl + "')"); } } } }
}
The above code was written by our previous senior web developer (that's what told to me when I was hired). On every item bound on the repeater he 1) reads the username from hidden control :doh: 2) call database to load user details :| 3) another call to database to check any active sessions :omg: 4) another call to load whole list of gps locations to find whether gps is enables or not :doh: 5) then finally enable the map button if gps is enabled Amazingly this list is inside an update panel that updated every 10 seconds :(( :(( So for an average list of 30 users => total 3x30 = 90 database calls every 10 seconds when i traced the page it was hauling at 320 Kb every 10 sec. X| Fixed this in database, bringing a bool flag back by doing some joins and determining weather gps is enabled or not. Now only 1 db call every 10 sec.