Azure Managed Instance - Query Slow vs On Prem

HSB 45 Reputation points
2024-08-20T12:49:06.7766667+00:00

I am testing moving our warehousing process from on prem to an Azure Managed Instance. After dropping a large set of stored procedures, the process has a task that will loop through tables, get all columns and recreate a procedure for each table that will handle Inserts, Updates, and Deletes. Basically, it is how we do change detection from our source and destination. For updates, we join on the primary key between source and destination and get results where any single column does not match between the two tables by scripting out the column names in a where clause checking for src.x <> dst.x

This single process takes about an hour on prem. In Azure Managed Instance, it is taking just under 2 hours if I tweak the query slightly or it times out as is when 2 hours is hit. I know I can increase the timeout but I need to speed this process up if we are to use Azure.

Our on prem databases are in simple recovery mode. Yes, I know Managed Instance is full and that can slow things down, but this seems extreme.

I've looked into some recommended steps using the QPI tools. Here's a screenshot of our Top 10 results from running SELECT * FROM qpi.wait_stats ORDER BY wait_time_s DESC. The results are after running the process a few times and stats were reset before beginning.
User's image

I'm unsure of how to handle these results and what I should look at possibly altering to see if it improves the times.

Also, are there other Azure tools that I should consider to check for new, updated, or deleted records in our source tables rather than continuing this old script process that we've had for over 10 years?

Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 64,901 Reputation points
    2024-08-26T18:34:10.61+00:00

    it is not clear what is taking 2 hours, creating the procs or running the procs.

    if it creating the proc's, then is the process an sql sp or script, or a client application?


Your answer

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