Groups | Blog | Home
all groups > dotnet ado.net > april 2008 >

dotnet ado.net : SqlCommand.ExecuteReader takes too much time


Achim Domma
4/16/2008 1:04:21 AM
Hi,

I have a table containing about 14,5 million records and I want to
iterate over the complete data. If I execute a "select * from
mytable", the call to ExecuteReader takes some hours to return. In T-
SQL I can open a cursor and start reading immediately. As far as I
understand, ExecuteReader/SqlDataReader should behave the same way -
but it seems like I'm wrong. Any hint?

regards,
Mary Chipman [MSFT]
4/16/2008 10:23:22 AM
What are you doing with 14 million rows? There are better ways to
export data from SQL Server. If you really want to use a reader, then
supply the nolock query hint to speed things up. See
http://blogs.msdn.com/sqlcat/archive/2007/02/01/previously-committed-rows-might-be-missed-if-nolock-hint-is-used.aspx
for more information.

--Mary

On Wed, 16 Apr 2008 01:04:21 -0700 (PDT), Achim Domma
[quoted text, click to view]
William Vaughn [MVP]
4/16/2008 7:12:21 PM
I'm with Mary. ADO.NET is NOT designed to provide a bulk data interface. I
have yet to see very many legitimate reasons to move that many rows to the
client. Processing that requires touching all the rows should be done on the
server if at all possible. Remember that if REALLY necessary (when TSQL is
not suitable) you can execute CLR procedures in VB.NET or C#. SELECT * is
also discouraged as it brings columns that you might not need. TSQL is no
different but consider that the operation is NOT returning any more than a
small cache of rows that is refreshed as you move through the rowset.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
[quoted text, click to view]
Cor Ligthert[MVP]
4/16/2008 7:38:58 PM
Achim,

Are you starting your "T-SQL", whatever you mean with that as the
DataReader uses as well T-SQL, from the same machine as your DataReader?

Cor

"Achim Domma" <domma@procoders.net> schreef in bericht
news:4965387f-2188-48ee-ba42-eda9368b4af5@y21g2000hsf.googlegroups.com...
[quoted text, click to view]
Cor Ligthert[MVP]
4/17/2008 5:32:06 AM
[quoted text, click to view]

That Summit brings everybody together.

:-)

Cor

[quoted text, click to view]
Achim Domma
4/23/2008 5:08:23 AM
On 17 Apr., 05:32, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
[quoted text, click to view]

Hi,

thanks to you all for your feedback. I'll think about redesigning my
process.

regards,
AddThis Social Bookmark Button