Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server stored procedure so fast in local so long in Azure

I have a SQL Azure database with a stored procedure that is returning just one row with 10 columns.

If I execute this stored procedure in Azure it takes 4 minutes.

Then I copied the database in local via dacpac file. So the database is exactly the same right?

When I executed the same stored procedure locally, then it takes less than 1 seconds.

Any idea? Can't be the network latency.

like image 265
Julian50 Avatar asked Sep 30 '22 01:09

Julian50


1 Answers

Erland Sommarskog solved my problem on msdn. So the solution was UPDATE STATISTICS by runnning "EXEC sp_updatestats" on the Database.

And the running time is now 1 seconds instead 4 min...

For more details: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/283bd059-0231-415f-99ec-284beeccbafb/sql-stored-procedure-so-fast-in-local-so-long-in-azure?forum=sqldatabaseengine#169873f3-7e39-4c52-995e-d8fb72abe7c2

like image 74
Julian50 Avatar answered Oct 02 '22 14:10

Julian50