Azurevariables表v临时表

这有点长; 但是我一直在通过查询来找出性能问题的来源。 感谢您花时间阅读。

我有一个运行在运行SQL Server 2012 @ Azure的专用服务器上的应用程序(西欧,如果有的话)。由于Azuresql中的function差距,我的应用程序不能在共享服务上运行。 过去运行的应用程序已经在各种2012服务器上运行,而且我注意到Azure和其他非Azure sql服务器之间奇怪的性能exception。

这个问题是围绕临时表 – 再次variables表v#表。

我们在Azure上发现,variables表的查询持续时间相当长; 很简单的例子; 每次运行50次并取平均值。

Create table #table (contactid uniqueidentifier, AnotherID uniqueidentifier) insert into #table select top 100 contactid, AnotherID from dbo.pdContacts 

v

 declare @table table (contactid uniqueidentifier, AnotherID uniqueidentifier) insert into @table select top 100 contactid, AnotherID from dbo.pdContacts 

Profiler说统计平均在;

  Variable Table : #Table CPU 47 : 16 Reads 379 : 204 Writes 11 : 0 Duration 83 : 42 

相同的查询,专用服务器上的数据库和没有负载返回

  Variable Table : #Table CPU 16 : 16 Reads 873 : 898 Writes 11 : 0 Duration 5 : 15 

在我非常简单的testing中,Azure Varianttesting几乎是#table执行持续时间的两倍; 在独立的设备上,这个变体是相当快的(对于小表来说,这与我们看到它的执行情况一致)。什么制约了Azure上比独立机器更明显的变体表的性能; 我可以在短期内对性能问题进行pipe理,而不是以牺牲其他人为代价优化应用程序。

谢谢