Slow performance of SqlDataReader

后端 未结 5 1507
栀梦
栀梦 2020-12-31 13:02

I\'ve query executing ~2 secs in MSSMS (returning 25K of rows)

Same query used in .NET (sqlReader) exetuting few minutes!

I\'ve also tried to execute only re

5条回答
  •  误落风尘
    2020-12-31 13:34

    I would check to see how long the actual retrieval is taking.

    for instance:

      Private Sub timeCheck()
        'NOTE: Assuming you have a sqlconnection object named conn
    
        'Create stopwatch
        Dim sw As New System.Diagnostics.Stopwatch
    
        'Setup query
        Dim com As New SqlClient.SqlCommand("QUERY GOES HERE", conn)
    
        sw.Start()
    
        'Run query
        Dim dr As SqlClient.SqlDataReader = com.ExecuteReader()
    
        sw.Stop()
    
        'Check the time
        Dim sql_query_time As String = CStr((sw.ElapsedMilliseconds / 1000)) & " seconds"
      End Sub
    

    This will allow you to see whether the hold-up is in the retrieval, or in the execution of the reader.

提交回复
热议问题