Share via

SQL Server Managed Instance slower than local SQL Server

Zohair Mehtab 0 Reputation points
2023-07-06T13:13:44.85+00:00

I have a database hosted on-premises with SQL Server. I use a 16 GB ram and core i-7 processor. Recently I migrated the database to SQL Server Managed Instance (with elastic pool). I use BCGen5 Elastic Pool with 10 vcores and 512 GB of space.

My database is using all the cores of elastic pool. But when I run a query on the cloud database it takes about 4 minutes to execute. Whereas, on my on-premises database it takes about 1 minute.

All metrics in the cloud database remains near 0% but the speed is about 5 times slower.

What can the issue be since the logs are not showing high usage for either CPU or any of the other metrics?

Azure SQL Database
SQL Server | Other

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 133.7K Reputation points MVP Volunteer Moderator
    2023-07-08T20:48:37.6766667+00:00

    The plans are not identical, but they are similar. Since they are only estimated plans, it is difficult to say if those differences matter or not. (Often bad performance is due to misestimates.)

    However, in the plans there are to cases of Nested Loops + Index Scan which stand out like a sore thumb. It seems to me than an index on ProcurementTrimsPurchaseOrderDetails.TrimsPrePurchaseOrderID would do wonders.

    I also get a feeling that the query itself can be improved. For instance, I am not sure that we need to access ProcurementTrimsPurchaseOrderDetails twice, but without further knowledge of table and data, this is a little precarious do, so I leave this for the moment.

    One small thing, though. Chance FORMAT(OrderDate,'yyyy-MM-dd') to convert(char(10), OrderDate, 121). FORMAT is implemented in the CLR and the context to the CLR can add insult to injury when there are many rows returned.

    0 comments No comments

  2. Anonymous
    2023-07-07T03:03:16.05+00:00

    Hi @Zohair Mehtab

    I found this link that describes the main reasons for the performance difference between SQL Managed Instance and SQL Server: https://azure.microsoft.com/en-us/blog/key-causes-of-performance-differences-between-sql-managed-instance-and-sql-server/, maybe you can use it as a reference.

    If the answer is helpful, please click Accept Answer and Up-Vote for the same. If you have any questions, please feel free to let me know.

    Best regards,

    Aniya

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.