Re: How does sql ExecuteReader() work?
- From: "William Vaughn" <billvaNoSPAM@xxxxxxxxx>
- Date: Thu, 16 Aug 2007 18:30:51 -0700
Each .NET Data Provider implements the low-level DataReader in its own way. However, (as I understand it) the SqlClient provider executes the query which begins a thread of execution on the server. At this point control returns immediately to the client which (in the case of the synchronous DataReader) the client provider waits for a back-channel packet that says the first row of the data is available. Your application blocks during this wait. The server (as I describe in Chapter 2 of my book), processes the SQL and once it finds rows that match the criteria saves the rows to a server-side buffer. Once the buffer is full or no more rows are found, the server signals the client over the open connection and blocks further operations (looking for more rows) until the client starts retrieving the rows. The client retrieves the rows in CacheSize blocks and signals the server to send more.This process is completed until all resultsets are processed or the connection is closed.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Avenger" <Avenger@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4DBAFD35-17BA-4BC6-9DE7-AC3426FD9F9D@xxxxxxxxxxxxxxxx
Hello,
I'd like to get a good general idea of how ExecuteReader works, behind
the scene. Obivously it executes what ever sql statement you passed in your
SqlCommand. But once that's done, is all the information passed back to your
application right away, or is the information taken one record at a time from
the database using the Read() command.
Does the database create a "temp memory" location where it holds this
request, and passes row by row back to the application with each Read(), or
does it shoot back in one shot the whole request back to your application,
and your SqlDataReader holds all the information, and the Read() simply let's
you handle each row one by one and do what ever you need to do with it.
Thanks for any help with this inquiry.
.
- Prev by Date: Parameter query won't work with an Array of Values
- Next by Date: Re: Looking for code sample to inset master and detail typed recordset
- Previous by thread: Parameter query won't work with an Array of Values
- Next by thread: Re: How does sql ExecuteReader() work?
- Index(es):
Relevant Pages
|
|