SQL SSMS VS .Net性能查询

问题描述 投票:0回答:1

我在我的电脑上安装了Sql Server Management Studio。

然后远程连接到我的一个数据库

我执行一个查询,在近1或2秒内返回6000条记录,但是当我从同一台PC运行相同的查询.Net应用程序(WPF桌面)时,数据传输大约需要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有不同的方式来管理传输的数据?

.net sql-server performance management-studio-express
1个回答
0
投票

好的,好像我在这个POST中找到了答案

Same query with the same query plan takes ~10x longer when executed from ADO.NET vs. SMSS

ado.net ConnectionString中的MultipleActiveResultsSet选项应为FALSE

和@DanGuzman感谢你清除这个。 “SSMS也使用ADO.NET。”

© www.soinside.com 2019 - 2024. All rights reserved.