June 25, 2019 at 11:03 am
Hi All,
We have sql server instance running on a VM which hosts 5 small dbs. Now they wanted to move those database to sql azure managed instance.
There is one important application database called "CDP" and it used heavily by the application team, now they are very particular about the response times of the queries, even after moving to Azure platform. As a proactive measure we as part of dba team, wanted to run some kind of light weight trace/extended event/serverside trace to capture the response times of the queries which are run against that specific database "CDP". Is this a good idea ? Secondly, question is how to capture the response time(s) of each n every query run against the database using extended event session. Thirdly, do we need to run a continuous trace or is there a better way to accomplish this?
Another question I have in my mind, do we need to actually go back to app team and check is there any specific queries to be monitored or each n every query to be captured?
Would like to know , what relevant questions do we need to really ask before going for migration in order to get predictive query performance.
Current SQL Server Version :
Microsoft SQL Server 2016 (SP2) Developer Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)
Regards,
Sam
June 25, 2019 at 11:39 am
The best tool for the job, if you want detailed query behaviors, is Extended Events. They are the least cost way to gather detailed query metrics. You only really need to capture two events, rpc_completed and sql_batch_completed. Those do everything you need. Now, another mechanism, that is also very lightweight, but not detailed, is to use the Query Store. There you'll get aggregate behaviors (grouped by hour out of the box, but this can be adjusted). This a great way to capture metrics when moment-by-moment details are not needed.
If you capture all the executions of all the queries, be prepared to handle the amount of data that entails. Be sure you capture the metrics to disk, but, not to the C:\ drive and not to the same disk that is storing your logs and/or data (or tempdb for that matter). You want to do this in a way that interferes as little as possible with standard operations.
To get started with Extended Events, you can't go wrong using the Microsoft documentation. I have a bunch of blog posts on the topic and a few videos. If you really want a lot of detail on how to use Extended Events in support of query tuning, then I recommend getting a copy of my book on the topic, linked below.
That's how to understand, the best way possible, how your queries are behaving. In addition, I'd be monitoring the wait statistics on your servers. All the same metrics are available in Managed Instances or in Azure SQL Database. Any time you're doing this kind of work, it's best to use the same metrics on both sides, collected, as much as humanly possible, the same way. Compare apples to apples, always. Nothing worse than capturing two different kinds of metrics and then attempting to compare them.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
June 25, 2019 at 4:35 pm
Hi Sir,
Thanks for the valuable inputs provided.
Couple of follow up questions?
1. Why we need to consider rpc_completed and why I can't I just go with sql_batch_completed? want to understand why rpc_completed is an important one?
2. What specific columns which I need to consider to calculate the response time of a query using the trace? is there specific columns like starttime & endtime and we substract the values and we get the response time ?
Regards,
Sam
June 25, 2019 at 5:14 pm
I gave you the bare minimum to get the job you asked for done. There are tons and tons of details you can go for, but if you're at the point that you don't know the best way to get the broad strokes done, better to focus only on the broad strokes. The details will wait until later.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
June 25, 2019 at 5:37 pm
Thank you very much Sir. Great information.
Only need to capture qry and its response time so that tomorrow they should come back and complain old or new server.
June 25, 2019 at 5:46 pm
+1 for Grant's advice to use XE.
June 26, 2019 at 5:01 pm
FWIW - I use an extended event on my system to capture any queries that take longer than 2 seconds to execute. I have the extended event set up to output to a file with rollover settings and max size settings. This allows me to look back over a time to see what queries have been taking a longer than normal duration.
When configuring the extended event - you can select specific columns to be returned or exclude columns that you don't need.
When you select the event - default fields will be selected for that event and you only need to configure it if you want to add/remove fields.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply