September 28, 2015 at 10:06 pm
Greetings, all.
I'm curious what are the most important/relevant stats, query plan aspects, etc., that you look at, when trying to determine if one T-SQL coding approach is more performant or efficient than another.
Thanks,
Randy
September 28, 2015 at 11:27 pm
Above all, how long it takes for the query to complete. Reads (something you can get using extended events or SET STATISTICS IO ON). I look at the query plan (I always develop in SSMS with "Include Actual Query Plan" turned on.) Things like sorts, implicit conversions are bad. Those are a few random things I look at.. It's a science - the more tuning you do, the better you get.
-- Itzik Ben-Gan 2001
September 28, 2015 at 11:33 pm
rwitt 95744 (9/28/2015)
Greetings, all.I'm curious what are the most important/relevant stats, query plan aspects, etc., that you look at, when trying to determine if one T-SQL coding approach is more performant or efficient than another.
Thanks,
Randy
Further on Alan's reply, looking at execution plans in isolation can be as misleading as looking at interior designs when trying to plan a city, you may occasionally get a good view but most of the time you don't.
π
September 29, 2015 at 1:31 am
Eirikur Eiriksson (9/28/2015)
rwitt 95744 (9/28/2015)
Greetings, all.I'm curious what are the most important/relevant stats, query plan aspects, etc., that you look at, when trying to determine if one T-SQL coding approach is more performant or efficient than another.
Thanks,
Randy
Further on Alan's reply, looking at execution plans in isolation can be as misleading as looking at interior designs when trying to plan a city, you may occasionally get a good view but most of the time you don't.
π
+1000
Rule #1 - know your data.
This opens up a whole bunch of doors. If you know your data you can anticipate data access paths and compare what you expect to see with what the optimiser spits out.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 29, 2015 at 4:36 am
For queries, execution time and the number of reads. I do use extended events for this all the time now. I've found that STATISTICS IO tends to mask changes in execution time for faster running queries, so rather than try to guess when it's interfering, I just skip it.
The number one concern for queries is that they run fast and do as little I/O as possible, so that's where I focus. When I can't see obvious improvements in the code, then I go to the execution plan and look for what's going wrong.
There's a whole lot more to it. Someone should write a book, or two
|
|
|
|
V
"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
September 29, 2015 at 4:38 am
Grant Fritchey (9/29/2015)
For queries, execution time and the number of reads. I do use extended events for this all the time now. I've found that STATISTICS IO tends to mask changes in execution time for faster running queries, so rather than try to guess when it's interfering, I just skip it.The number one concern for queries is that they run fast and do as little I/O as possible, so that's where I focus. When I can't see obvious improvements in the code, then I go to the execution plan and look for what's going wrong.
There's a whole lot more to it. Someone should write a book, or two
|
|
|
|
V
About time someone did:-D
π
September 29, 2015 at 7:47 am
When I'm tuning a system, I look at the aggregate IO, CPU and duration of the queries over a fixed period of time, usually an hour or two, in peak business time. For individual queries, I'm going trying to minimise reads, duration and CPU. I'll use the execution plan to he in doing so, but the plan is not going to tell me which of multiple queries is most efficient.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply