Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Looks like a database call obsession to me…

Looks like a database call obsession to me…

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasedesignquestionannouncement
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saxenaabhi6
    wrote on last edited by
    #1

    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.

    F S R 3 Replies Last reply
    0
    • S saxenaabhi6

      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.

      F Offline
      F Offline
      Firo Atrum Ventus
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • S saxenaabhi6

        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.

        S Offline
        S Offline
        StM0n
        wrote on last edited by
        #3

        saxenaabhi6 wrote:

        senior web developer

        ... and now? retired? ;) Little bit of a question... was he willing to rethink what've done?

        (yes|no|maybe)*

        S 1 Reply Last reply
        0
        • S StM0n

          saxenaabhi6 wrote:

          senior web developer

          ... and now? retired? ;) Little bit of a question... was he willing to rethink what've done?

          (yes|no|maybe)*

          S Offline
          S Offline
          saxenaabhi6
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • S saxenaabhi6

            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

            S Offline
            S Offline
            StM0n
            wrote on last edited by
            #5

            The kind of company, that relies more on titles... :doh:

            (yes|no|maybe)*

            1 Reply Last reply
            0
            • S saxenaabhi6

              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.

              R Offline
              R Offline
              RobCroll
              wrote on last edited by
              #6

              UserProfile selectedUser = null;
              selectedUser = Sql.GetUserDetails(username.Value);

              You might want to confirm that your KPI isn't based on the number of lines you write.

              "You get that on the big jobs."

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups