Hello.
I'm having a bit of trouble with the performance of a parameterized sql statement. The table i'm working with has ~150,000 records with each record having ~30 columns.
This statement executes in 3.5 seconds.
Dim selectstring As String
selectstring = "SELECT * FROM LineInfo WHERE jobNum=@jobnum and revision_number=@revnum AND lineNum=@linenum;"
Dim selectCommand As New SqlClient.SqlCommand(selectstring, Singleton.DbConnection)
selectCommand.Parameters.Add("@jobnum", "testing1")
selectCommand.Parameters.Add("@revnum", "0")
selectCommand.Parameters.Add("@linenum", 13)
Dim da As New SqlClient.SqlDataAdapter(selectCommand)
Dim ds As New DataSet
Try
da.Fill(ds)
MsgBox("Done.")
ds.Dispose()
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
da.Dispose()
This select statement executes in .0015 seconds.
Dim selectstring As String
selectstring = "SELECT * FROM LineInfo WHERE jobNum='testing1' and revision_number=0 AND lineNum=13;"
Dim selectCommand As New SqlClient.SqlCommand(selectstring, Singleton.DbConnection)
Dim ds As New DataTable
Dim a As New SqlClient.SqlDataAdapter(selectCommand)
Try
a.Fill(ds)
MsgBox("Done.")
ds.Dispose()
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
a.Dispose()
I've read some here on the forum about parameter sniffing but that seems to pertain to stored procedures. I'm not really sure where to go from here so I thought I'd try you all here at stack overflow. Does anyone know what could be causing this issue?