Identifying and Fixing Parameter Sniffing Issues

  Рет қаралды 48,637

Brent Ozar Unlimited

Brent Ozar Unlimited

Күн бұрын

Brent's live session at SQLDay Poland 2017. You'll learn 4 things: what parameter sniffing is, how to react to parameter sniffing, how NOT to test your code, and options to fix the problem long term.

Пікірлер: 58
@DivakarRaj
@DivakarRaj Жыл бұрын
This session is gold. Absolute pure gold !! Pure class from Brent
@BrentOzarUnlimited
@BrentOzarUnlimited Жыл бұрын
Thanks, glad you liked it!
@mtsurov
@mtsurov 3 жыл бұрын
I watched this several times and endlessly thankful that this material exists. Thank you Brent ! (p.s. Your humor is not lost on me either).
@kenigiri
@kenigiri 5 жыл бұрын
I think this is the first time I understood this Parameter Sniffing concept to this level. Very clear explanation and very powerful tool sp_Blitz
@marancibia1971
@marancibia1971 3 жыл бұрын
What a great session! A lot of practical knowledge. Thanks!
@themortu
@themortu 4 жыл бұрын
amazing presenter, the best i've seen, thank you so much for telling us serious things in this funny and easy way
@krneki6954
@krneki6954 6 жыл бұрын
brent ozar never fails! great videos
@chiragbhatt2244
@chiragbhatt2244 4 жыл бұрын
Very deep, clear session. Great presentation. Would definitely like to polish my skills in sql and may be opt for paid training at some point. What I liked most was the practical scenarios you explained. Awesome work. Thanks !!
@ganeshjraj
@ganeshjraj 2 жыл бұрын
What a legend!! Absolutely loved the session..
@datanalan5215
@datanalan5215 6 жыл бұрын
You are special!!! Thanks for the great video!!!
@rvijayteja
@rvijayteja 2 ай бұрын
How the heck did I never know temp stored procedures even existed. Great session
@parnet
@parnet 3 жыл бұрын
This is such a good session and really shows the issues succinctly.
@BrentOzarUnlimited
@BrentOzarUnlimited 3 жыл бұрын
Thanks!
@bluerays5384
@bluerays5384 2 жыл бұрын
Amazing Session Brent...A lot of learning today.Mindblowing. looking for more sessions.
@andreabruschetta8791
@andreabruschetta8791 Жыл бұрын
Interesting demo about parameter sniffing, and ... funny "anchor-man". I liked it.
@BrentOzarUnlimited
@BrentOzarUnlimited Жыл бұрын
Glad you enjoyed it!
@neoritch
@neoritch 4 жыл бұрын
you are such an amazing presenter!
@RodrigoMatela
@RodrigoMatela 8 ай бұрын
I wish I got teachers like you! Absolute legend! Cheers
@BrentOzarUnlimited
@BrentOzarUnlimited 8 ай бұрын
Thanks!
@monday6740
@monday6740 5 жыл бұрын
Brent is such a good presenter ! 47:10 The compiler could obviously ignore ALL comment when parsing the statement for use of query parsing, so that you can actually put comments into a statement. Remember: developers are instructed to put "useful" info in there. Same with upper and lower reserved words, they should be treated the same. Other things have similar issues, but this is part of the compiler's job; it should rebuild the statement to a uniform format - similar to like when you read in into the document, where it states the default method of using reserved words and such.
@AsailingDIYlifechannel
@AsailingDIYlifechannel 4 жыл бұрын
Not often I find anything I can use in my job on KZbin as an ERP developer. But wow this was extremely helpful. I spent all night last night figuring out a way to get around this exact problem and have now put a "patch" on it using a Plan Guide adding a index hint. Unfortunately the stats is weird and makes sometimes a very strange plan on a table with 200.000.000+ records. It will make it run for almost ever. When I add the hint it's done in 0 seconds. Any thoughts on Plan Guides? We are currently on a SQL Server 2012.
@eugenechen8240
@eugenechen8240 3 жыл бұрын
HI Brent, if you do a select into temp table rather than get all the result into display in SSMS, then the execution time will be better distinguished between bad and good plans.
@ScottLucas58
@ScottLucas58 4 жыл бұрын
Thank you! Did not know I was wasting my time with the local variable testing.
@alllle81
@alllle81 5 жыл бұрын
impressive presentation...
@alrivera3358
@alrivera3358 3 жыл бұрын
Learned a lot. thanks Brent
@poojajoshi8551
@poojajoshi8551 3 жыл бұрын
Very nicely explained. Very helpful 👍
@BrentOzarUnlimited
@BrentOzarUnlimited 3 жыл бұрын
Glad it was helpful!
@chihanglui222
@chihanglui222 4 жыл бұрын
It is a veey clear explaination and your sp is very useful
@marcosdiez7263
@marcosdiez7263 2 жыл бұрын
Great explanation. I wonder whether another alternative would be possible to the OPTION FOR VALUE, to minimize the implied future maintenance overload of the procedure, which is to have a procedure to be called at server startup or when updating stats that in turn makes a call to the problematic store procedures with the desired VALUE. The drawback would be that at those times there would be a redundant and functionally unneeded load to the server, but then each bussiness logic store procedure would be devoted solely to the bussiness logic aspect as supposed to, and this startup called procedure would gather all the logic devoted to the parameter sniffing problem as a technical database proprietary aspect (or even better, if there exist a chance, to cache the SP plan without executing the actual queries, but I don't know how). Then, in the worst case in which data distribution changes, you would have the parameter sniffing issue triggered again but once detected, you need a single modifictation to the startup procedure to get the issue solved (moreover, DBA would be able to modify the startup procedure without altering bussiness logic procedures that may be critical for the customer which could be prone to introduce undesired side effects, not to mention a concurrent modification in which the programmer dealing with the bussiness logic could reintroduce the value you just corrected).
@BrentOzarUnlimited
@BrentOzarUnlimited 2 жыл бұрын
We'd love to watch you do a presentation on KZbin about how you solved that problem in that way.
@koushikdey100
@koushikdey100 4 жыл бұрын
U r smiply superb Brent, watched 👀 this video 🎥 and liked it very much.Thanks🌹
@dinhba6859
@dinhba6859 3 жыл бұрын
Tks Brent. Love this.
@BrentOzarUnlimited
@BrentOzarUnlimited 3 жыл бұрын
Glad you enjoyed it!
@rliy001
@rliy001 4 жыл бұрын
Hi, Question. You mentioned in the presentation that SQL remembers how much memory it needs to execute the proc when its first compiled; but I thought you also mentioned that sql determines there's "lots of work" or "small amount of work" involved when it first executes [by sniffing the params that comes in]... So which is correct?
@BrentOzarUnlimited
@BrentOzarUnlimited 4 жыл бұрын
Ruch - it only sniffs the *first* set of parameters, not all of them.
@rliy001
@rliy001 4 жыл бұрын
Hi Brent. You mentioned SQL tipping point for "screw-you, I'm going to to scan the entire table" was when having to read ~5% of total pages. However, my copy of stackoverflow (50GB) version, has Users table that is using ~50K pages. Reputation=2 query brings 1800 rows (5700 logical reads). That is ~11% of the pages. However, it is still happily doing the index seek + key lookup. Can you explain why? PS: running SQL2016 DEV Total rows in users table 2465713; consuming 50K pages
@TheBrentOzar
@TheBrentOzar 4 жыл бұрын
Sure, read this: www.brentozar.com/archive/2020/05/no-you-cant-calculate-the-tipping-point-with-simple-percentages/
@rliy001
@rliy001 4 жыл бұрын
@@TheBrentOzar Thanks! So we will leave it as one of those wonderful mysteries of the SQL Black-box?
@martinrousev
@martinrousev 5 жыл бұрын
Much appreciated! Very good stuff. I wanted to ask if and how all this is related to forced parametrization.
@TheBrentOzar
@TheBrentOzar 5 жыл бұрын
Sure, we cover that in detail in our training class, Mastering Server Tuning. (It's beyond what I can do in a KZbin comment though.)
@rliy001
@rliy001 4 жыл бұрын
Hi Brent, Why am I not getting the same number that sql cardinal estimator uses when local params are used. Your example, you were able to work out the exact number 314 Using density x total rows I don't get the same number sql ce uses
@TheBrentOzar
@TheBrentOzar 4 жыл бұрын
Sure, that's exactly the kind of question I cover in my Fundamentals of Parameter Sniffing class. You can enroll at my site.
@aroratripti_
@aroratripti_ 4 жыл бұрын
I loved this video.
@BrentOzarUnlimited
@BrentOzarUnlimited 4 жыл бұрын
Thanks, glad you liked it.
@RC-nn1ld
@RC-nn1ld 5 жыл бұрын
fandabidozi, superb Brent as always!
@r.s.4174
@r.s.4174 2 жыл бұрын
You should really post the link to Erwins blog.
@sandeepmaryala2035
@sandeepmaryala2035 4 жыл бұрын
Hi Brent. so finally what would be a good plan to avoid sniffing?
@TheBrentOzar
@TheBrentOzar 4 жыл бұрын
It's beyond what I can cover here in a KZbin comment, but I continue that discussion in my Mastering Query Tuning class.
@PD-df8rc
@PD-df8rc 2 жыл бұрын
Can parameter sniffing resolve using query store?
@BrentOzarUnlimited
@BrentOzarUnlimited 2 жыл бұрын
To find out, take my Mastering Parameter Sniffing class.
@Alexu72u
@Alexu72u 6 жыл бұрын
Thank you!
@sudarshana2827
@sudarshana2827 6 ай бұрын
Note Whenever you see parameter sniffing, identify and apply covering index.
@BrentOzarUnlimited
@BrentOzarUnlimited 6 ай бұрын
Bad news: you are not correct. Time to attend my Fundamentals and Mastering Parameter Sniffing classes. Cheers!
@dtovee
@dtovee 4 жыл бұрын
Cool :) Thanks for the knowledge share.
@rliy001
@rliy001 4 жыл бұрын
Still have pen in midair waiting for the answer that does not SUCK
@mgs3866
@mgs3866 4 жыл бұрын
liked it
@damarh
@damarh 3 жыл бұрын
He was not being sarcastic about Erlands blog, omg!
@shaikhussain474
@shaikhussain474 4 жыл бұрын
Wooh, now I got answer for my boss, lol
Blocking and Locking: How to Find and Fight Concurrency Problems
58:29
Brent Ozar Unlimited
Рет қаралды 51 М.
Watch Brent Tune Queries 2020
51:32
Brent Ozar Unlimited
Рет қаралды 25 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
What is Parameter Sniffing in SQL Server?
18:02
SQLMaestros
Рет қаралды 6 М.
SQL Query Optimization. Why is it so hard to get right?
1:39:24
Brent Ozar Unlimited
Рет қаралды 37 М.
Getting Started with the Consultant Toolkit
34:58
Brent Ozar Unlimited
Рет қаралды 9 М.
Brent Ozar_Watch Brent Tune Queries
1:06:57
SQLugSWE
Рет қаралды 65 М.
Watch Brent Tune Queries - SQLSaturday Oslo
1:01:54
Brent Ozar Unlimited
Рет қаралды 48 М.
Deadlocks: Lets Do One, Understand It, and Fix It
44:01
SQLBits
Рет қаралды 39 М.
SQL Day 2022 - Why is the Same Query Sometimes Slow - Brent Ozar
57:14
Data Community Poland
Рет қаралды 1,2 М.
Microsoft SQL Server Performance Tuning, Live
54:30
Brent Ozar Unlimited
Рет қаралды 117 М.
7 Database Design Mistakes to Avoid (With Solutions)
11:29
Database Star
Рет қаралды 101 М.
SQL performance tuning and query optimization using execution plan
49:23
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН