I have a few Oracle procedures that generate/return a large amount of data that I need to write out to a file. I’m currently trying to accomplish with a data-reader. It seems to be working, I’ve successfully generated a 479mb file without any trouble. It took less than 4 minutes from the time I retrieved the dataReader to complete the file.
But the dataReader I get for a particular procedure is crawling. It’s unbelievably slow. I modified my code to try and get a better idea of what is going on….
System.Diagnostics.Debug.Write("Performing .Read() on DataReader: ")
Dim d1 As DateTime = DateTime.Now
Dim result As Boolean = myDataReader.Read()
Dim ts As TimeSpan = DateTime.Now.Subtract(d1)
System.Diagnostics.Debug.WriteLine(ts.ToString)
The interesting this is that my output ends up looking like this:
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:00:00
Performing .Read() on DataReader: 00:07:33.5037500
I’m really at a loss for what to do next. I can’t see anything unique or different about the row that takes 07:33.5037500. Any suggestions?
EDIT:
Thanks for the responses everyone. First, as best as I can tell, no exceptions are being thrown. As suggested, I’ve taken a look at this particular procedure that is exhibiting the behavior above and while procedure is ridiculously massive; but it looks like it uses a lot of cursors to populate an oracle temp table. The Ref Cursor that is returned is a SELECT * FROM that temp table.
I’m writing a PL/SQL block that will open that cursor to see if the performance issue exists when I remove the .Net code….hopefully that will help; but if you’ve got any additional thoughts, it will be much appreciated.
Thanks once more. This does appear to be a PL/SQL issue and not a .NET problem.
What is the database actually doing ?
A query with a GROUP BY or and ORDER BY may need to generate the full result set, then sort/aggregate it before returning a row. A query scanning a large table may find 50 rows in the first couple of blocks, then read another hundred thousand blocks before it finds another one.
I suggest you ignore the VB code and post the database code.