Azure SQL stored procedure ridiculously slow called from C# Azure SQL stored procedure ridiculously slow called from C# azure azure

Azure SQL stored procedure ridiculously slow called from C#


Have you ruled out environmental issues? Check your allocation of memory, disk space, cpu, and network bandwidth for your azure server. SQL is a hog for both memory and disk space.

But you probably already checked all that. My next guess would be the connection string. You'll definitely need to use different syntax in the connection string for connecting to an Azure Sql instance as opposed to a local/network hosted one. See connectionstrings.com for details on the azure specific connection string syntax. (Remember that Azure Sql Server is different software than regular Sql Server. They try to look the same and pretend to behave the same, but they really are different under the hood.) It's possible that something like authentication or encryption is the bottleneck. Especially authentication is likely to be different between your SSMS connection and your code connection string.


When you call your SP from C# you should include the name of the database:

[YourDatabaseName].[dbo].[usp_DevelopmentSearch_Select]

In SSMS, your database will most likely be active. Hence, the server will know which database you are querying. When running on your local server, you most likely have very few databases (perhaps only one?). Hence, your local server will know which database you are querying.

But, in Azure you may very well have multiple databases, so it might need to scan through multiple databases. That will explain the delay you are seeing.