Comments on: Something Smells: Parameter Sniffing https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/ Thomas LaRock is an author, speaker, data expert, and SQLRockstar. He helps people connect, learn, and share. Along the way he solves data problems, too. Wed, 29 Apr 2015 14:50:11 +0000 hourly 1 https://wordpress.org/?v=6.7.2 By: madone_99301 https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8021 Mon, 11 Feb 2013 23:40:00 +0000 http://thomaslarock.com/?p=10117#comment-8021 In reply to ThomasLaRock.

I try to avoid clearing the plan cache whenever possible. I have a couple scripts that identify the most expensive queries by polling the sys.dm_exec_query_stats DMV. Clearing the plan cache not only gets rid of the data that would alert me to potential performance issues in the database, but also puts the instance back in warm-up mode as all the stored procedures need to be compiled again.

I run Ola Hallengren’s index defrag and maintenance scripts on our servers, so the statistics aren’t my primary suspect when I see symptoms of parameter sniffing. My first instinct is to pull up the execution plan and compare the compile time and run time values for input parameters, thanks to Grant Fritchey’s session on parameter sniffing at SqlConnections last year.

In a couple instances I’ve added OPTION (RECOMPILE) to a stored procedure, or OPTION (OPTIMIZE FOR @Parameter = N’Some Value’) and had pretty good luck with both of those. Does anybody else have some tricks that work?

Andre Ranieri

]]>
By: ThomasLaRock https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8012 Fri, 08 Feb 2013 14:57:00 +0000 http://thomaslarock.com/?p=10117#comment-8012 In reply to Chris Fradenburg.

Chris,

Nice example there of how by giving SQL Server a little nudge in the right direction everything can work well.

]]>
By: ThomasLaRock https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8013 Fri, 08 Feb 2013 14:57:00 +0000 http://thomaslarock.com/?p=10117#comment-8013 In reply to Ayman El-Ghazali.

Ha!

]]>
By: Chris Fradenburg https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8011 Fri, 08 Feb 2013 14:53:00 +0000 http://thomaslarock.com/?p=10117#comment-8011 I actually just fixed an issue by “enabling” parameter sniffing. Ad hoc SQL in a job declared a variable then populated it with getdate()-2. After taking the variable out the estimated number of rows returned from the table dropped from over 3 milling to 18 thousand. Compared to the 10 thousand rows actually returned it was much better.

]]>
By: Ayman El-Ghazali https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8010 Fri, 08 Feb 2013 13:25:00 +0000 http://thomaslarock.com/?p=10117#comment-8010 Tried this on a couple of our older servers. Looks like no one has put it in before my time here. I guess their ignorance was bliss in this case.

]]>
By: ThomasLaRock https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8009 Fri, 08 Feb 2013 02:07:00 +0000 http://thomaslarock.com/?p=10117#comment-8009 In reply to Rob Volk.

Nice!

]]>
By: Rob Volk https://thomaslarock.com/2013/02/something-smells-parameter-sniffing/#comment-8008 Thu, 07 Feb 2013 20:32:00 +0000 http://thomaslarock.com/?p=10117#comment-8008 You know what you’d call 10,000 instances of SQL Server at the bottom of the ocean?

Still cheaper than 1 instance of Oracle!

/ba-dum-ching /here all week /try the veal

]]>