How to Stop Parameter Sniffing in SQL Server

Sdílet
Vložit
  • čas přidán 7. 08. 2017
  • Are your query parameters being sniffed by SQL Server? Learn how to recognize and solve parameter sniffing performance problems in your SQL queries. Links below.
    Blog post: blog.bertwagner.com/why-param...
    Follow me on Twitter:
    / bertwagner
    Want to receive the latest weekly blog posts and videos in your inbox? Sign up for the newsletter here: upscri.be/c77fc8/
  • Věda a technologie

Komentáře • 19

  • @hovardlee
    @hovardlee Před 3 lety +2

    Watch Brent Ozar on yt about it.
    It is quite normal that your data can change. This is why you are tuning your queries over time. This is nothing wrong cause your data is growing constantly and this is why you have your job :)

  • @grandetaco4416
    @grandetaco4416 Před 3 měsíci

    I like the 3rd option, but hate it too and not just for maintenance. The idea of having to put that through peer review and production approval would be lovely to explain to others as well as documenting everything so people know why you have duplicate code.

  • @AlejandroBelloRD
    @AlejandroBelloRD Před 3 lety +1

    Most excellent nit-picky explanation on how to force the optimizer to work for you. Especially useful for, for example, SSRS.

  • @CharlieArehart1
    @CharlieArehart1 Před 5 lety +1

    Great explanation, Bert. It's a problem that has plagued many for years (even decades). There are still other solutions one could consider, and more have been added to later and later versions of SQL Server. (And actually, the problem can plague more than just SQL Server.)
    But this is a really well-done demonstration of the problem and some basic solutions which may be all many need. Thanks for the effort!

  • @gopiadabala3562
    @gopiadabala3562 Před 5 lety +2

    Fantastic explanation Bert, this really helped me.
    I have resolved many issues in my environment(ETL) with this energy.
    Thank you for investing your time in such a great knowledge sharing session.

  • @shaikzuhair8537
    @shaikzuhair8537 Před 4 lety +1

    Clear and good explanations.in very short period of time

  • @ssrakeshsharma
    @ssrakeshsharma Před 6 lety +1

    Hey Nicely Explained, Thanks from Afghanistan

  • @tao5198
    @tao5198 Před 4 lety

    Thx for good explanation!

  • @randeepsinghmatharu9071
    @randeepsinghmatharu9071 Před 6 lety +3

    First 2 options are great and often used. The 3rd option as you explained, can be a nightmare especially if for example, new countries are added to your table that aren't specifically optimised for in the procedure.
    Another option surprisingly not mentioned, is declaring local variables in your SP that pick up the variables past through say an application like SSRS. This avoids parameter sniffing altogether... A blessing but occasionally a curse too! Good video!!

    • @gopiadabala3562
      @gopiadabala3562 Před 5 lety

      Good analysis, but Bert already told about the maintenance which required for option 3 :-)

  • @natanaelmontes1836
    @natanaelmontes1836 Před 2 lety

    Saludos desde México muy buena explicación y sobre todo explicas la solución contundente.

  • @FlashDark
    @FlashDark Před 6 lety +2

    It's really hot in there (thanks for the explanation) ^^

  • @notcranium
    @notcranium Před 6 lety

    Good video. Thanks for making it! That espresso shot extraction at the end was terrible though! 10.5 seconds is way too fast! You need to grind it finer to get it up to ~28 seconds (assuming the volume of coffee is good as well as the tamping pressure being adequate). :)

  • @aurelianpaulmuresan5326
    @aurelianpaulmuresan5326 Před 4 lety +1

    Good video. Do you know how can I improve the performance into a stored procedure that has multiple table type parameters? I added the option recompile but that didn't help too much.

    • @erwinekkel9676
      @erwinekkel9676 Před 4 lety

      Easy do not use table parameters. Instead use temp tables

  • @ettyobz
    @ettyobz Před 6 lety

    Clap clap

  • @christianrodier3381
    @christianrodier3381 Před 3 lety

    All options have their trade offs

  • @sergolobovi767
    @sergolobovi767 Před 6 lety

    what happened with your right ear???

  • @ngwustephen3035
    @ngwustephen3035 Před 4 lety

    I get this error, "mysql.connector.errors.ProgrammingError: Not enough parameters for the SQL statement" in mysql, please how do I resolve it?