none
How much data can be stored in network buffer when datareader is used RRS feed

  • Question

  • all we know that datareader works like

    The datareader reads a record at a time, but it reads it from the underlying database driver. The database driver reads data from the database in blocks, typically using a buffer that is 8 kilobytes.

    If your result records are small and you don't get very many, they will all fit in the buffer, and the database driver will be able to feed them all to the data reader without having to ask the database for more data.

    If you fetch a result that is larger than the buffer, you will only be able to read the first part of it and when there will no data exist in network buffer then datareader will inform sql server to send next block of data.

    here is small code how we use data reader

    String selectString = "SELECT * FROM PRODUCT";  
        IList<client> clients = new List<client>();  
        using (var selectCommand = new OracleCommand(connection, selectString))  
        {  
            using (OracleDataReader selectReader = selectCommand.ExecuteReader())  
            {   
               if (selectReader.HasRows)  
               {  
                   while (selectReader.Read())  
                   {  
                       clientes.add( GetDomainObject(selectReader) );  
                   }  
                   selectReader.close();  
               }  
            }
        }  

    suppose PRODUCT table has 10,000 records. so i like to know how much data can accommodate in network buffer at a time?

    because when datareader.ExecuteReader() will call then reader will fetch a block of data and stored in network buffer in that pc. when datareader.read() will call then single data will be forwarded to reader from buffer. when all read wil be read from buffer then a database call will made again and next block of data will be stored in buffer.

    i am just curious to know how much data a data reader can stored in buffer when data fetch from db. data reader will always fetch a fixed number of rows from db & stored in buffer or does it depend on buffer size?

    buffer size depend on what....does it depend on ram ?

    please discuss only the network buffer related things because i know how data reader works. thanks

    Friday, March 21, 2014 8:59 AM

Answers

  • Hello,

    As far as I know, the Stream will be used when we use the DataReader to fetch data from database. As we can see that it has a parameter “size“ which is Int32 type and it shows the number of bytes to read from the NetworkStream, the max value is 2^32. However, as it uses the TCP to do the network stream transaction, its default buffer size is 8192 bytes. See it here.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, March 24, 2014 3:38 AM
    Moderator