我已经在我的PC中安装了Sql Server Management Studio。
然后远程连接到我的一个数据库
我执行一个查询,将在近1或2秒内返回6000条记录,但是当我从同一台PC上从.Net应用程序(WPF Desktop)运行同一查询时,数据传输将花费近8-9秒
我在.Net中的代码非常简单明了
这是代码
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
Dim Sql_Connection As New SqlClient.SqlConnection("MyRemoteSQLConnectionString")
Dim Sql_Command As New SqlClient.SqlCommand("select Col1,Col2,Col3,Col4,Col5,Col6 from Table", Sql_Connection)
Sql_Connection.Open()
dr = Sql_Command.ExecuteReader
Dim DataTable As New DataTable
DataTable.Load(dr)
'The above code takes 8-9 seconds to finished but in ssmo takes only 1-2 seconds for 6000 Records
Sql_Connection.Close()
End Sub
为什么会这样?剂量ssms有不同的方法来管理数据传输?
OK,似乎我在此POST中找到了答案
从ADO.NET与SMSS执行时,具有相同查询计划的相同查询花费的时间要长大约10倍
ado.net ConnectionString中的MultipleActiveResultsSet选项应为FALSE
@DanGuzman感谢您清除此问题。“ SSMS还使用ADO.NET。”
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句