0

I deployed my application on Azure, The database I created on Azure runs query slower. On Actual Server My query runs in 0.45 seconds and on SQL Azure My query runs in 14 second. Following is my query

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 )

Can anyone help please as soon as possible I shall be thankful Thankx

Hannah Vernon
  • 3,367
  • 1
  • 26
  • 48
ISK
  • 85
  • 1
  • 9
  • 2
    what you mean by ASAP ?? Trying to Boss Us – mohan111 Oct 09 '15 at 12:51
  • 1
    This entirely depends on the processing power of your on-site SQL box compared to the DTU's you have allocated to your Azure SQL Instance. The Azure SQL Tiers vary greatly in their performance capabilities. – connectedsoftware Oct 09 '15 at 12:54
  • 2
    http://stackoverflow.com/questions/31086778/why-is-running-a-query-on-sql-azure-so-much-slower – mohan111 Oct 09 '15 at 12:57
  • you should probably move `where t1.SerialNum = @serialNum` inside your subquery for one.. – JamieD77 Oct 09 '15 at 13:33
  • Thankx, I did but It did not create any difference can u please suggest something other if you have – ISK Oct 09 '15 at 13:37
  • If you just "lifted and shifted" the database to run in Azure, could you explain what kind of database you are using? Are you using [SQL Server in a VM](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-sql-server-infrastructure-services/) or are you using [Azure SQL Database](https://azure.microsoft.com/en-us/services/sql-database/). Additionally could you explain the performance characteristics of both the on-prem server and the VM or Database in Azure? – elfisher Oct 09 '15 at 13:47

1 Answers1

0

You need to increase the DTUs on your Azure SQL Server instance or use a bigger virtual machine. I am guessing here, but likely your on site server is beefier than the one you allocated in Azure.

David Crook
  • 2,722
  • 3
  • 23
  • 49