locked
DataSet/DataReader Performance RRS feed

  • Question

  • Hi,

    I've run some tests on fetching data from a SQL Server 2005 database using a DataSet and a DataReader.

    In my database, I'm calling a stored procedure that fetches one record from a table.  The Sql Server Profiler says the call takes between 20 - 50 ms (within SqlServer).  The C# application and Sql Server are on the same machine.

    DataSet - performance: average 575ms (for steps 3 & 4) :

    1.) Create Connection

    2.) Create Command

    3.) Create Adapter

    4.) Fill DataSet using Adapter

    DataReader - performance: average 200ms (for steps 3 & 4):

    1.) Create Connection

    2.) Create Command

    3.) Execute Reader

    4.) Read with Reader

    Does this performance jibe with what others have seen? 

    Can the performance be improved either on the DataSet or the DataReader?

    Any feelings on how performance will be affected with larger record sets? 

     

     

     

    Thursday, July 27, 2006 12:14 AM

Answers

  • Hi,

    the only thing that would be really affecting the performance would be to decrease the retrieved data with choosing some parameters / filters in the condition.


    HTH, Jens Suessmeyer-

    ---
    http://www.sqlserver2005.de
    ---

    Saturday, July 29, 2006 12:18 AM

All replies

  • This is by design. A datareader is a readonly forward cursor which is optimized for reading data. It should be prefered whenever reading data from a datasource.



    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

    Thursday, July 27, 2006 6:40 AM
  • Hi Jens,

    Thanks for the reply.  Are there variants that can be set to opimize the read performance of the datareader (meaning to decrease the 200ms time to respond)?

    Thanks,

     

    Andy

    Thursday, July 27, 2006 11:10 PM
  • Hi,

    the only thing that would be really affecting the performance would be to decrease the retrieved data with choosing some parameters / filters in the condition.


    HTH, Jens Suessmeyer-

    ---
    http://www.sqlserver2005.de
    ---

    Saturday, July 29, 2006 12:18 AM