多少数据可以存储在网络缓冲区用于DataReader的时 [英] How much data can be stored in network buffer when datareader is used

查看:145
本文介绍了多少数据可以存储在网络缓冲区用于DataReader的时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道,DataReader的工作方式类似于

all we know that datareader works like

DataReader的每次读取记录,但它从底层数据库驱动程序读取它。数据库驱动程序从数据库中读取的块数据,通常使用缓冲区是8千字节。

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.

如果您获取这一结果比缓冲区大,你只能够读取它的第一部分,当将在网络缓冲区不存在数据,那么DataReader的将通知SQL服务器发送数据的下一个块。

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.

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();  
           }  
        }
    }  



假设产品表有10,000条记录。所以我想知道有多少数据可以在网络缓冲区同时容纳?

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

因为当 datareader.ExecuteReader()将调用那么读者将获取的数据块,并存储在网络缓冲区中的PC。当 datareader.read()将调用然后单数据从缓存转发给读者。当所有读西港岛线从缓冲区中读取,然后一个数据库调用将再次进行和数据的下一个块将被存储在缓冲区中。

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

推荐答案

根据您的设置对此有读的默认结果集处理和多活动结果集并的行集和SQL Server游标

Depending on your setup have a read of this Default Result Set Processing and Multiple Active Result Sets and Rowsets and SQL Server Cursors

看到的 TcpClient.ReceiveBufferSize 的,它会告诉你是多么的原始数据在一次操作中读取。

Look into TcpClient.ReceiveBufferSize it will tell you how much raw data can be read in one operation.

的ReceiveBufferSize属性获取或设置你期待在接收缓冲区存储每个读取操作的字节数。这个属性实际上操纵分配用于接收输入数据网络缓冲空间。

"The ReceiveBufferSize property gets or sets the number of bytes that you are expecting to store in the receive buffer for each read operation. This property actually manipulates the network buffer space allocated for receiving incoming data.

您网络缓冲区应至少一样大,你的应用程序的缓冲区,以保证所需的数据将可当你调用NetworkStream.Read方法。使用ReceiveBufferSize属性将此大小设置。如果你的应用程序将接收大量的数据,你应该通过Read方法非常大的应用程序的缓冲区。

Your network buffer should be at least as large as your application buffer to ensure that the desired data will be available when you call the NetworkStream.Read method. Use the ReceiveBufferSize property to set this size. If your application will be receiving bulk data, you should pass the Read method a very large application buffer.

如果网络缓冲区比数据,你要求的金额较小Read方法,你将不能够检索在一个读操作的数据的期望量。这招对Read方法调用额外的开销。

If the network buffer is smaller than the amount of data you request in the Read method, you will not be able to retrieve the desired amount of data in one read operation. This incurs the overhead of additional calls to the Read method."

,然后阅读的 NetworkStream.Read

此时,您将有回答你的问题的复杂性更好的主意。

At which point you will have a better idea of the complexity of the answer to your question.

这篇关于多少数据可以存储在网络缓冲区用于DataReader的时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆