niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Why does first reader.Read take all time in stead of command.ExecuteReader?
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Ed Prochak
*nix forums Guru Wannabe


Joined: 17 Mar 2005
Posts: 271

PostPosted: Fri Feb 04, 2005 4:57 pm    Post subject: Re: Why does first reader.Read take all time in stead of command.ExecuteReader? Reply with quote

I've got no answer for you, just an observation:

--- the posted code:

Debug.WriteLine("Starting first Read at " +
System.DateTime.Now.TimeOfDay);

while (reader.Read())
{
Debug.WriteLine("Finished Reading at " +
System.DateTime.Now.TimeOfDay);
}

--- does not correspond to the posted output:
Starting first Read at 15:07:58.203 0.016
Finished first Read at 15:08:07.922 9.719

So maybe you forgot to recompile?
Back to top
Roel Schreurs
*nix forums beginner


Joined: 14 Mar 2005
Posts: 3

PostPosted: Fri Feb 04, 2005 7:53 am    Post subject: Why does first reader.Read take all time in stead of command.ExecuteReader? Reply with quote

Hi All,

Nobody responded while posting to
microsoft.public.dotnet.framework.adonet, maybe someone here has a
clue.

I am using either CoreLab.Oracle.dll (2.40.2.0) or
Oracle.DataAccess.dll (9.2.0.2102) and ADO.NET to access an Oracle9i
Enterprise Edition Release 9.2.0.1.0 - Production server.

In C#, I am using CoreLab/ORANET classes to access the database.
Typically, I
create a command object of CommandType StoredProcedure and open a
reader on it. The Procedure returns a ref cursor.

I am surprised to see that the command.ExecuteReader() takes little
time (e.g. 0.1 s) to complete, while the first reader.Read() takes
much more time (e.g. 10 s). In fact, if I execute the procedure some
other way (SQL editor in Toad), execution time is comparable to the
time reader.Read takes.

ExecuteReader would correspond to OPEN <cursor> and Read would
correspond to FECTH <cursor> INTO <record>.

I do not think that command.ExecuteReader works asynchronously, since
putting the thread to Sleep for 10 seconds does not help reader.Read
to complete faster.

Does anybody know why this is so?

The point is that I am allowing the user to cancel ExecuteReader, but
the user never gets a chance, since it completes immediately.

See below for details.

Thanks in advance,

Roel Schreurs

// Sample code
OracleDataReader reader = null;

OracleConnection conn = new OracleConnection("<ConnectionString>");
conn.Open();
OracleCommand command = conn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "<Package>.<Procedure>";

OracleParameter parameter = command.CreateParameter();
parameter.OracleDbType = OracleDbType.RefCursor;
parameter.ParameterName = "<CursorVariable>";
parameter.Direction = ParameterDirection.Output;
command.Parameters.Add(parameter);

Debug.WriteLine("Starting ExecuteReader at " +
System.DateTime.Now.TimeOfDay);

reader = command.ExecuteReader();

Debug.WriteLine("Finished ExecuteReader at " +
System.DateTime.Now.TimeOfDay);

//Optional Thread.Sleep(10000);

Debug.WriteLine("Starting first Read at " +
System.DateTime.Now.TimeOfDay);

while (reader.Read())
{
Debug.WriteLine("Finished Reading at " +
System.DateTime.Now.TimeOfDay);
}

-- Results:
Starting ExecuteReader at 15:07:58.063
Finished ExecuteReader at 15:07:58.188 0.125
Starting first Read at 15:07:58.203 0.016
Finished first Read at 15:08:07.922 9.719

Starting ExecuteReader at 15:04:27.859
Finished ExecuteReader at 15:04:27.984 0.125
Starting first Read at 15:04:38.000 10.016
Finished first Read at 15:04:47.688 9.688
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 2:22 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Running php file everyday on scheduled time sachin PHP 1 Fri Jul 21, 2006 12:49 pm
No new posts Solaris dd command problem prak Solaris 0 Fri Jul 21, 2006 5:43 am
No new posts Solaris dd command problem prak Solaris 0 Fri Jul 21, 2006 5:43 am
No new posts Solaris dd command problem prak Solaris 4 Fri Jul 21, 2006 5:43 am
No new posts ConfigParser: what read('non-existent-filename') returns ... Danil Dotsenko python 4 Thu Jul 20, 2006 5:50 pm

Mortgages | Credit Counseling | Anime | Internet Advertising | Western Union Money Order
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1909s ][ Queries: 20 (0.1085s) ][ GZIP on - Debug on ]