sql-server - Azure SQL 在处理多行时非常慢

标签 sql-server azure azure-sql-database

在我的 Azure SQL 数据库 (S0 10 DTU) 中,我有一个包含 80k 行的 Products 表。

我正在从 Management Studio 运行以下查询:

UPDATE Product 
set IsActive = 'true'

它运行了近 3 分钟,利用了近 100% 的数据库资源。

在我的本地计算机(SQL Server Express)上,相同的查询在10秒内对100倍大的表执行.

Azure SQL 出了什么问题?它适合多行操作吗?我的本地配置非常差,但它的性能远远优于 Azure SQL。

DTU 到底是什么?来自 this link我实在无法说出他们所说的“交易”是什么意思。是单行读/写访问吗?

如果我需要在数据库上执行多行操作,我是否应该迁移到具有 SQL Sever Express 的虚拟机?

编辑

统计

SQL Server Express

执行时间:26秒

enter image description here enter image description here

Azure SQL

执行时间:1m 23s

enter image description here enter image description here

最佳答案

这里很少有东西..

1.首先,您将 AZure DB 与本地数据库进行比较无效

2.其次,您的执行计划可能会根据各种因素而改变,并且客户统计数据不会有帮助..

为了进行真正的比较,请执行以下操作..

a.)Set SSMS option to discard result sets on both instances

b.)set statistics IO on

现在,通过丢弃结果集,网络延迟被消除,并且统计 io 打开,我们可以看到 Azure DB 是否由于内存压力而从磁盘读取

一旦进行了真正的比较,您可以检查更多内容以查看查询运行时的等待类型。

select * from sys.dm_exec_query_stats st
cross apply
sys.dm_exec_sql_text(st.sql_handle) txt

根据等待类型,您可以进一步排除故障,例如,如果您看到高页面 Io Latch 等待类型,则意味着该表的页面不在内存中。

关于sql-server - Azure SQL 在处理多行时非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36529273/

相关文章:

sql-server - Entity Framework 表命名约定

sql-server - Visual Studio Azure SQL Server : no connection could be made because the target machine actively refused it

azure - 从 AWS 发布到 Azure EventHub

sql-server - 具有多个 DbContext 的事务,每个事务在 Entity Framework 上都有自己的连接

azure - SymmetricDS 集群实现高可用性

c# - EF 代码优先 - 配置没有共享 PK/FK 的一对零或一关系

sql - 根据同一 select 语句中先前计算的行(或列)计算新行(或列)

php - 查询 mssql 数据库分页返回错误

python - Azure Batch NodePreparationError 尝试从 Azure 容器注册表获取 Docker 镜像

azure - 如何在Azure Function中使用LinQ lambda表达式并将其与Azure SQL连接