SQL在Azure上执行速度较慢

时间:2015-10-09 12:45:52

标签: sql-server azure-sql-database

我在Azure上部署了我的应用程序,我在Azure上创建的数据库运行查询速度较慢。在实际服务器上我的查询在0.45秒内运行,在SQL Azure上我的查询在14秒内运行。以下是我的查询

DECLARE @serialNum NVARCHAR(MAX) = '0075'
DECLARE @serialNumSelected NVARCHAR(20) ,
@sku NVARCHAR(20) ,
@description NVARCHAR(100) ,
SELECT  @serialNumSelected = t1.SerialNum ,
    @sku = t2.SKU ,
    @description = t2.Description ,
    @animateAssigneeId = t1.AnimateAssigneeId ,
    @inanimateAssigneeId = t1.InanimateAssigneeId ,
    @numLabels = t3.NumLabelsPrinted ,
    @isPersonal = ( CASE WHEN LOWER(t4.Name) = 'personal' THEN 1
                         ELSE 0
                    END ) ,
    @dateDueBy = t1.DateDueBy
FROM    ( SELECT    t1.SerialNum ,
                t1.RubberGoodSKUId ,
                t2.AnimateAssigneeId ,
                t2.InanimateAssigneeId ,
                t2.DateDueBy
      FROM      dbo.SerializedRubberGoods t1 WITH ( NOLOCK )
                LEFT JOIN ( SELECT  * ,
                                    ROW_NUMBER() OVER ( PARTITION BY SerializedRubberGoodId ORDER BY DateTested DESC ) AS rn
                            FROM    dbo.SerializedRubberGoodsCycles c WITH (NOLOCK)
                          ) t2 ON t1.SerializedRubberGoodId = t2.SerializedRubberGoodId
                                  AND t2.rn = 1
    ) t1
    INNER JOIN dbo.RubberGoodSKUs  t2 ON t1.RubberGoodSKUId = t2.RubberGoodSKUId
    INNER JOIN dbo.RubberGoodTypes t3 ON t2.RubberGoodTypeId = t3.RubberGoodTypeId
    INNER JOIN dbo.RubberGoodCategories t4 ON t3.RubberGoodCategoryId = t4.RubberGoodCategoryId
WHERE   t1.SerialNum = @serialNum
OPTION  ( RECOMPILE )

任何人都可以尽快帮助 我会感恩的 Thankx

0 个答案:

没有答案