Note that there are some explanatory texts on larger screens.

plurals
  1. POODP.Net - OracleDataReader.Read very slow
    primarykey
    data
    text
    <p>I'm having a lot of trouble with the OracleDataReader in ODP.Net. Basically, I have a parameterized query that takes anywhere from 1-5 seconds to run (returning around 450 records) and then takes 60-90 seconds to loop over (with no code even running in the loop, literally iterating over the recordset and doing nothing).</p> <p>When I run it from Aqua Data Studio it takes 1-5 seconds. When I run it from .Net it takes 1-5 seconds for cmd.ExecuteReader() to return. When I loop over the 450 records with OracleDataReader.Read it takes 60-90 seconds to finish.</p> <p>I even took out all of the code in the loop and just had a blank "While dr.Read" and it still took 60 to 90 seconds to loop over those 450 records (I used a Stopwatch to get the time for the cmd.ExecuteReader and then around the empty dr.Read loop).</p> <p>I have tried setting the FetchSize, it didn't help (and, it's only 450 records in my test case). I have tried turning auto tuning off with the connection string, it degraded performance even more.</p> <p>Why is the OracleDataReader.Read taking so long when it's a small amount of data being returned (and other tools return the same data for the same query in a fraction of the time)? </p> <pre><code> Using conn As New Oracle.DataAccess.Client.OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings("oracle_dss").ConnectionString) conn.Open() Using cmd As OracleCommand = conn.CreateCommand cmd.BindByName = True cmd.CommandText = "" ' removed SQL to make this more readable ' Month end Dim paramMonthEndDate As OracleParameter = cmd.CreateParameter paramMonthEndDate.ParameterName = ":month_end_date" paramMonthEndDate.DbType = DbType.Date paramMonthEndDate.Value = monthEnd cmd.Parameters.Add(paramMonthEndDate) Dim sw As New System.Diagnostics.Stopwatch sw.Start() cmd.FetchSize = 1000 Dim dr As OracleDataReader = cmd.ExecuteReader dr.FetchSize = dr.RowSize * 1000 sw.Stop() Me.Log(String.Format("Month End Query: {0}s", sw.ElapsedMilliseconds / 1000)) sw.Reset() sw.Start() While dr.Read End While sw.Stop() Me.Log(String.Format("Month End Query through recordset: {0}s", sw.ElapsedMilliseconds / 1000)) dr.Close() End Using conn.Close() End Using </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload