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. General Programming
  3. C#
  4. High performance: DataGridView1.DataSource = MyDataTable (100,000 rows) [modified]

High performance: DataGridView1.DataSource = MyDataTable (100,000 rows) [modified]

Scheduled Pinned Locked Moved C#
performancetutorialquestioncode-review
15 Posts 6 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.
  • G god4k

    MyDataTable get data(rows) from Xml file not from database. If I use MyDataTable.DefaultView.RowFilter = "xxx", it will spent time for this process instead. 8 to 9 seconds is not fast enough for me. Is there any idea to improve performance?

    K Offline
    K Offline
    kubben
    wrote on last edited by
    #5

    Break up the xml file to smaller files and load the correct one base off whatever RowFilter you are planning on setting. Ben

    1 Reply Last reply
    0
    • G god4k

      MyDataTable get data(rows) from Xml file not from database. If I use MyDataTable.DefaultView.RowFilter = "xxx", it will spent time for this process instead. 8 to 9 seconds is not fast enough for me. Is there any idea to improve performance?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #6

      An XML file is a just a Text file. It takes a LONG time for the DataSet class to load AND PARSE that much stuff. 8 to 9 seconds for a file that big is GOOD. You simply have no choice but to break that file down into smaller chunks, organized how you want it filtered, then load only those files that you need. There is no other way to speed this up...

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        An XML file is a just a Text file. It takes a LONG time for the DataSet class to load AND PARSE that much stuff. 8 to 9 seconds for a file that big is GOOD. You simply have no choice but to break that file down into smaller chunks, organized how you want it filtered, then load only those files that you need. There is no other way to speed this up...

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #7

        Dave Kreskowiak wrote:

        8 to 9 seconds for a file that big is GOOD.

        No kidding, especially for an XML file. Talk about bitching over spilled milk... If it is such a big deal, then he needs to refactor the problem into a smaller file like kubben recommended.

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          You're retrieving 100,000 rows and 8 to 9 seconds isn't fast enough for you?? Hint: Retrieve less rows! If you're not doing anything with ALL of those rows, there's no reason to retrieve them, now is there?

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          G Offline
          G Offline
          god4k
          wrote on last edited by
          #8

          8-9 seconds that I tell you not include Load AND PARSE Xml file. DateTime d1 = DateTime.Now; DataGridView1.DataSource = MyDataTable DateTime d2 = DateTime.Now; TimeSpan ts = d2 - d1; Console.WriteLine(ts); Thank You.

          D P 2 Replies Last reply
          0
          • G god4k

            Dear, Sir and Madam How to improve performance for the code below? DataGridView1.DataSource = MyDataTable; //(MyDataTable contains 100,000 rows) The code above spent About 8-9 seconds that so long. Thank You. NOTE: WinForm not WebForm -- modified at 12:39 Wednesday 25th July, 2007

            M Offline
            M Offline
            martin_hughes
            wrote on last edited by
            #9

            The DataGridView can be a pretty slow control to render large amounts of data, and as noted by others, it looks as if you're getting pretty good performnace. However, performance, and the illusion of performance are not quite the same thing. If your application looks as if it has hung during this 8-9 second load, then users might suspect it as having crashed. In which case, you might like to have this loading happening in a different thread, at least that way you can update the UI with a natty progress bar or similar. Taking this approach, however, may actually slow down the load - but the user will probably think it works more quickly than if the screen just locks up.

            "It was the day before today.... I remember it like it was yesterday." -Moleman

            1 Reply Last reply
            0
            • G god4k

              8-9 seconds that I tell you not include Load AND PARSE Xml file. DateTime d1 = DateTime.Now; DataGridView1.DataSource = MyDataTable DateTime d2 = DateTime.Now; TimeSpan ts = d2 - d1; Console.WriteLine(ts); Thank You.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #10

              god4k wrote:

              8-9 seconds that I tell you not include Load AND PARSE Xml file.

              Then why did you say so?!?

              god4k wrote:

              DateTime d1 = DateTime.Now; DataGridView1.DataSource = MyDataTable DateTime d2 = DateTime.Now; TimeSpan ts = d2 - d1; Console.WriteLine(ts);

              You're not seriously rendering 100,000 rows in a dataGrid, are you?? Is the user even going to look at all of that crap?? You really need to rethink your design, 'cause there is no way to speed up the rendering of 100,000. What does the user need to see?? That is all you should be showing them. I can't think of a single good reason to show a user 100,000 rows of a table...

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              1 Reply Last reply
              0
              • G god4k

                Dear, Sir and Madam How to improve performance for the code below? DataGridView1.DataSource = MyDataTable; //(MyDataTable contains 100,000 rows) The code above spent About 8-9 seconds that so long. Thank You. NOTE: WinForm not WebForm -- modified at 12:39 Wednesday 25th July, 2007

                G Offline
                G Offline
                Gyan Jadal
                wrote on last edited by
                #11

                Have you given a thought of using the Virtual mode in the Datagrid? GJ

                D 1 Reply Last reply
                0
                • G god4k

                  8-9 seconds that I tell you not include Load AND PARSE Xml file. DateTime d1 = DateTime.Now; DataGridView1.DataSource = MyDataTable DateTime d2 = DateTime.Now; TimeSpan ts = d2 - d1; Console.WriteLine(ts); Thank You.

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #12

                  Cut the amount of data down as Dave has said. Only pull up the data that the user is going to be using at the moment, and 100,000 rows is not going to be the case. Allow the user to filter the rows he/she is going to need.

                  "The clue train passed his station without stopping." - John Simmons / outlaw programmer

                  D 1 Reply Last reply
                  0
                  • G Gyan Jadal

                    Have you given a thought of using the Virtual mode in the Datagrid? GJ

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #13

                    Nice idea, but it's not a solution to the root cause of the problem - poor design.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    1 Reply Last reply
                    0
                    • P Paul Conrad

                      Cut the amount of data down as Dave has said. Only pull up the data that the user is going to be using at the moment, and 100,000 rows is not going to be the case. Allow the user to filter the rows he/she is going to need.

                      "The clue train passed his station without stopping." - John Simmons / outlaw programmer

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #14

                      Why is it that no machine is fast enough for some "developers"??? :sigh:

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                           2006, 2007

                      P 1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        Why is it that no machine is fast enough for some "developers"??? :sigh:

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                             2006, 2007

                        P Offline
                        P Offline
                        Paul Conrad
                        wrote on last edited by
                        #15

                        No kidding. I've got a P4 running at 2.5ghz and 1gig ram. It fits the bill for my development projects. I even have test station boxes running between 233mhz and 1.8ghz :->

                        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                        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