简体   繁体   English

Azure SQL 服务器所需时间是本地 SQL 服务器的 10 倍

[英]Azure SQL Server takes 10 times as long as a on-premise SQL Server

I have a Visual Studio VB.NET project that basically runs a large number of queries against a database.我有一个 Visual Studio VB.NET 项目,它基本上对数据库运行大量查询。

After moving the database from a local on-premise SQL Server to Azure SQL, the performance dropped significantly.将数据库从本地本地 SQL 服务器移动到 Azure SQL 后,性能显着下降。

Of course it will be slower.当然会慢一些。 But it's 10 times slower... Latency is of-course the issue here.但它慢了 10 倍……延迟当然是这里的问题。

Are there any ways to increase speed?有什么方法可以提高速度吗? Something "smart" in the connection string or command object?连接字符串或命令 object 中有什么“智能”?

I cannot change the "architecture" of the project (out of my hands).我无法更改项目的“架构”(无法控制)。 It has to be a lot (5000+) of small queries that return one value (running one at the time).必须有很多(5000+)个小查询返回一个值(当时运行一个)。

Here is an example of what I mean.这是我的意思的一个例子。 Running this on a "local" SQL Server takes 10 seconds - in Azure, it takes 200 seconds:在“本地”SQL 服务器上运行它需要 10 秒 - 在 Azure 中,需要 200 秒:

Dim Server As String = "AZURE.poweranalyzedevazuretest.database.windows.net"
Dim User As String = "*****"
Dim password As String = "******!"
Dim PRODUCTIONDATABASE As String = "MYDB"

Dim SQL_CONNECTION_STRING As String = "Server=" & Server & "; Database=" & PRODUCTIONDATABASE & "; User Id=" & User & "; Password=" & password & ";"

Dim SDataSet = New DataSet
Dim SDataAdapter = New SqlClient.SqlDataAdapter
Dim SCommand As New SqlClient.SqlCommand
Dim CurrConnection = New SqlConnection(SQL_CONNECTION_STRING)
CurrConnection.Open()
Debug.Print(Now().ToString)

For i = 1 To 1000
    SCommand.Connection = CurrConnection
    SCommand.CommandText = "SELECT 'Hello World'"
    Dim p As Object = SCommand.ExecuteScalar()
Next

CurrConnection.Close()
Debug.Print(Now().ToString)

/perove /perove

I ran your code against an on-prem SQL Server instance and it ran in well under 1 second.我针对本地 SQL 服务器实例运行了您的代码,它运行时间不到 1 秒。 Same code against Azure SQL Database (basic tier) ran in 60 seconds.针对 Azure SQL 数据库(基本层)的相同代码在 60 秒内运行。 This test is measuring network latency rather than database performance.该测试测量的是网络延迟而不是数据库性能。

I expect running the code in Azure, especially in the same region as the db, will provide performance comparable to running both on-prem.我希望在 Azure 中运行代码,尤其是在与数据库相同的区域中,将提供与在本地运行两者相当的性能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 本地 SQL 服务器到 Azure PostgreSQL 复制 - On-premise SQL Server to Azure PostgreSQL replication 将Azure SQL数据库镜像到本地SQL Server - Mirroring Azure SQL Database to an on-premise SQL Server 如何从 Azure Synapse 连接到本地 SQL 服务器 - How to connect to on-premise SQL Server from Azure Synapse 具有本地SQL Server和最佳实践的Azure搜索数据源? - Azure Search DataSource with on-premise SQL Server and best practices? 如何从 Azure Powershell 运行手册连接到本地 SQL 服务器? - How to connect to an on-premise SQL Server from Azure Powershell runbook? 如何通过从 SQL 服务器(本地)到 Azure SQL 数据库的查询/脚本设置定期迁移 - How to set up recurring migration through queries/script from SQL server(On-premise) to Azure SQL database 从本地 SQL 服务器 SSRS 连接到在线 SQL Azure DB - Connect TO Online SQL Azure DB FROM On-Premise SQL Server SSRS 通过Windows Azure Connect将Azure托管的Ruby on Rails应用程序连接到本地SQL Server - Connect Azure-hosted Ruby on Rails app to on-premise SQL Server through Windows Azure Connect 使用Azure本地网关连接到SQL Server高可用性群集时出错 - Error Connecting to SQL Server High Availability Cluster using Azure On-Premise Gateway 是否可以为连接到本地SQL Server的Azure数据工厂指定ApplicationIntent = ReadOnly? - Is it possible to specify ApplicationIntent = ReadOnly for Azure Data Factory connecting to on-premise SQL Server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM