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. Database & SysAdmin
  3. Database
  4. Loading Data on Demand

Loading Data on Demand

Scheduled Pinned Locked Moved Database
databasecsharpsql-serversysadminquestion
12 Posts 5 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.
  • Richard Andrew x64R Richard Andrew x64

    I'm using ADO.NET. Entity Framework is not an option. Suppose I have an IDataReader instance that was created from calling a stored procedure that returns 150,000 rows. If I create a DataTable, and then call DataTable.Load(IDataReader), does it: 1. Read all available rows into the table at once? 2. Read only those rows that are necessary to return whatever rows I read from the DataTable? 3. Some hybrid of the above two scenarios? I'm interested in implementing a solution that only reads data from the server upon demand. IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server. Thank you very much for your insight.

    The difficult we do right away... ...the impossible takes slightly longer.

    M Offline
    M Offline
    Mycroft Holmes
    wrote on last edited by
    #3

    I agree with Richard, 150k records to the UI is only valid if you are doing a data dump and there are more efficient way to do that.

    Never underestimate the power of human stupidity RAH

    Richard Andrew x64R 1 Reply Last reply
    0
    • Richard DeemingR Richard Deeming

      #1 - it loads all of the rows into memory at once. DataTable.Load | Reference Source[^] Displaying 150,000 rows on screen in one hit is not a good idea. How is the poor user ever going to find the one row they're interested in? There must be some way to summarise, filter, or page the data to make it easier to consume.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #4

      Thanks for your response. I only chose 150,000 as a theoretical number to make my point. There would never be that many rows, but in our main LOB application, some developers in the past have loaded up around 10,000 rows, making the form rather slow to open!

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      • M Mycroft Holmes

        I agree with Richard, 150k records to the UI is only valid if you are doing a data dump and there are more efficient way to do that.

        Never underestimate the power of human stupidity RAH

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #5

        Yes, I agree with you and Richard. I'm working on creating a generic way to load the data only on demand. It must be a business object agnostic way. Thanks. :)

        The difficult we do right away... ...the impossible takes slightly longer.

        M 1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          I'm using ADO.NET. Entity Framework is not an option. Suppose I have an IDataReader instance that was created from calling a stored procedure that returns 150,000 rows. If I create a DataTable, and then call DataTable.Load(IDataReader), does it: 1. Read all available rows into the table at once? 2. Read only those rows that are necessary to return whatever rows I read from the DataTable? 3. Some hybrid of the above two scenarios? I'm interested in implementing a solution that only reads data from the server upon demand. IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server. Thank you very much for your insight.

          The difficult we do right away... ...the impossible takes slightly longer.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          Richard Andrew x64 wrote:

          IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server.

          Then how? You mentioned a "form", so I'd assume WinForms with a DataGridView. In which case you don't use a datatable, but a list. You add to the list from a different thread, in batches of 50. Virtualize the DataGridView. Start the actions as soon as the form is displayed.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

          Richard Andrew x64R 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Yes, I agree with you and Richard. I'm working on creating a generic way to load the data only on demand. It must be a business object agnostic way. Thanks. :)

            The difficult we do right away... ...the impossible takes slightly longer.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #7

            If you are using SQL Server I think there is a method of loading a "page" of data which my be valid. Obviously I have never used it, I limit UI lists to a max of 2k. After that filters become mandatory.

            Never underestimate the power of human stupidity RAH

            Richard Andrew x64R 1 Reply Last reply
            0
            • M Mycroft Holmes

              If you are using SQL Server I think there is a method of loading a "page" of data which my be valid. Obviously I have never used it, I limit UI lists to a max of 2k. After that filters become mandatory.

              Never underestimate the power of human stupidity RAH

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #8

              We have one form that displays Purchase Orders, and the data goes back to 2009. There are thousands upon thousands of records. How can you limit how many rows you load, and yet still allow the user to type in a column filter string in order to find any of the PO's from any point in time?

              The difficult we do right away... ...the impossible takes slightly longer.

              1 Reply Last reply
              0
              • L Lost User

                Richard Andrew x64 wrote:

                IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server.

                Then how? You mentioned a "form", so I'd assume WinForms with a DataGridView. In which case you don't use a datatable, but a list. You add to the list from a different thread, in batches of 50. Virtualize the DataGridView. Start the actions as soon as the form is displayed.

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                Richard Andrew x64R Offline
                Richard Andrew x64R Offline
                Richard Andrew x64
                wrote on last edited by
                #9

                Eddy Vluggen wrote:

                You add to the list from a different thread, in batches of 50

                Thank you. That's one of the avenues I am exploring. I have to find some way to make our application more responsive while still enabling access to thousands of rows.

                The difficult we do right away... ...the impossible takes slightly longer.

                L 1 Reply Last reply
                0
                • Richard Andrew x64R Richard Andrew x64

                  I'm using ADO.NET. Entity Framework is not an option. Suppose I have an IDataReader instance that was created from calling a stored procedure that returns 150,000 rows. If I create a DataTable, and then call DataTable.Load(IDataReader), does it: 1. Read all available rows into the table at once? 2. Read only those rows that are necessary to return whatever rows I read from the DataTable? 3. Some hybrid of the above two scenarios? I'm interested in implementing a solution that only reads data from the server upon demand. IOW, I don't want my form to only appear on screen after all 150,000 rows have been pulled from SQL Server. Thank you very much for your insight.

                  The difficult we do right away... ...the impossible takes slightly longer.

                  J Offline
                  J Offline
                  Jorgen Andersson
                  wrote on last edited by
                  #10

                  ADO.Net support paging the data into the dataset if you use an Adapter. Paging Through a Query Result[^] DbDataAdapter.Fill Method (DataSet, Int32, Int32, String) (System.Data.Common)[^]

                  Wrong is evil and must be defeated. - Jeff Ello

                  Richard Andrew x64R 1 Reply Last reply
                  0
                  • Richard Andrew x64R Richard Andrew x64

                    Eddy Vluggen wrote:

                    You add to the list from a different thread, in batches of 50

                    Thank you. That's one of the avenues I am exploring. I have to find some way to make our application more responsive while still enabling access to thousands of rows.

                    The difficult we do right away... ...the impossible takes slightly longer.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #11

                    Loading from a background-thread sounds ideal then; the IDataReader will return an array of objects, and stuffing them into a list is fast. List<object[]> :) Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control[^] - fastest way to display a huge amount of data. ..and searching the list of object-arrays could also be done on a background-thread, simply by going through the list :)

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                    1 Reply Last reply
                    0
                    • J Jorgen Andersson

                      ADO.Net support paging the data into the dataset if you use an Adapter. Paging Through a Query Result[^] DbDataAdapter.Fill Method (DataSet, Int32, Int32, String) (System.Data.Common)[^]

                      Wrong is evil and must be defeated. - Jeff Ello

                      Richard Andrew x64R Offline
                      Richard Andrew x64R Offline
                      Richard Andrew x64
                      wrote on last edited by
                      #12

                      Thank you, this looks very promising. :)

                      The difficult we do right away... ...the impossible takes slightly longer.

                      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