8 Replies Latest reply on Jun 8, 2010 9:01 PM by mkalam

    Datagrid takes too long to load large data

    mkalam

      Hi, I am using flex datagrid to populate data from Sql server 2005. Table contains 18,850 rows in it. But datagrid grid takes 10-15 mins to load and sometimes it does’t show data after waiting 20mins.
      Here is code that i am using:

      string XMLresult = “”;
      string conString;
      conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
      SqlConnection connection = new SqlConnection(conString);
      connection.Open();
      SqlCommand result1 = new SqlCommand(sql, connection);
      SqlDataReader reader1 = result1.ExecuteReader();
      bool resultHasRows = reader1.HasRows;

      if (resultHasRows == true)
      {
      XMLresult = “”;
      XMLresult = XMLresult + “”;
      while (reader1.Read())
      {
      XMLresult = XMLresult + “”;
      XMLresult = XMLresult + “” + reader1.GetValue(1).ToString() + “”;
      XMLresult = XMLresult + “” + reader1.GetValue(3).ToString() + “”;
      XMLresult = XMLresult + “” + reader1.GetValue(18).ToString() + “”;
      XMLresult = XMLresult + “”;
      }
      reader1.Close();
      connection.Close();
      XMLresult = XMLresult + “”;
      Response.Write(XMLresult);
      }
      else
      {
      Response.Write(“false”);
      }

        • 1. Re: Datagrid takes too long to load large data
          UbuntuPenguin Level 4

          How long does it take for the server call to complete , i.e what amount of time does it take to push out all of that XML. How long does it take to parse all of that XML on the Flex side.  In addition , if you are using a databinding on your datagrid which I assume you are , that could be adding some slow-up to the process.  Since the collection fires an update event for each item added.

          • 2. Re: Datagrid takes too long to load large data
            Flex harUI Adobe Employee

            Server-side probably isn't the problem.  What does the Flex side look like?

            Are you converting the XML to objects?  That can take a while.

            • 3. Re: Datagrid takes too long to load large data
              UbuntuPenguin Level 4

              Hey HarUI ,

                      This should probably be another post but I have a question that is semi-related. Lets say I have a large number of objects ( think millions ) that I get parse from XML and place into an array.  Now if I have an arraycollection and I do ac.source = itemArray , does the collection fire 1 single update event , or does it fire a whole bunch.

                    About a year ago , I saw a video where people where talking about the performance hit incurred by the data-binding on the arraycollection and was wondering if this was a way around it.

               

              Ubu.

               

              I don't mind putting this in another post if you would like the points.

              • 4. Re: Datagrid takes too long to load large data
                BhaskerChari Level 4

                Hi mkalam,

                 

                Its better to use DataGrid paging by displaying a maximum number of records and fetch the results only for the displayed results based on the pageIndex (by querying based on startIndex and endIndex in backend database).

                 

                This way you could far better reduce the time delay as you are not fetching the total results one time but only getting the feew results based on the results per page.

                 

                Hope it helps...

                 

                If this post answers your question or helps, please kindly mark it as such.


                Thanks,

                Bhasker Chari

                1 person found this helpful
                • 5. Re: Datagrid takes too long to load large data
                  mkalam Level 1

                  Thanx Ubu ,HarUI and Bhasker Chari, i am pretty much aware of the fact that paging takes much  less to display records, but the problem here is I need to show user all the record on single page. It took 10-15 mins for the datagrid to populate 18,850 records even from single DB table.

                  • 6. Re: Datagrid takes too long to load large data
                    Flex harUI Adobe Employee

                    Remember that DataGrid only makes as many renderers as are visible.  Since

                    there is no way to show all 18,850 records at once, one option is to bring

                    in a bunch and then get more later.

                     

                    However, it must also be noted that the Flash Player has a maximum 60 second

                    timeout.  If any loop or recursion does not complete in 60 seconds, the

                    application will be halted and continue on the next frame.  Therefore it

                    seems possible that something else is going on.

                     

                    Try using the profiler to see where all that time is going.

                    1 person found this helpful
                    • 7. Re: Datagrid takes too long to load large data
                      SpaghettiCoder Level 3

                      So you have a app, that will show a user 18500 records all at once?

                       

                      ignoring the load time, how does all that data even fit all on the screen at a time.

                       

                      you have a app that's 1900x1200?

                      • 8. Re: Datagrid takes too long to load large data
                        mkalam Level 1

                        yes, you are right. I am using 1920x1200 screen resolution. But I will try profiler, lets see how it goes.