6 Query Tuning Techniques - Solve 75% SQL Server Performance Problems (by Amit Bansal)

Поделиться
HTML-код
  • Опубликовано: 8 фев 2025
  • SQL Server Performance Tuning Master Class is happening again. Learn more. bit.ly/SQLMaes...
    Want Amit Bansal to deliver a private batch for your team members? Drop an email to contact@sqlmaestros.com
    Want access to Master Class recordings for a lifetime? Explore here: bit.ly/SQLM_MCR
    Amit Bansal frequently delivers free webinars for the SQL community. Learn more: bit.ly/SQLMaes...
    Join the SQLMaestros WhtsApp Community: chat.whatsapp....

Комментарии • 85

  • @rohitsakalle
    @rohitsakalle 3 года назад +37

    Very nice content....8:10 Non Sargability , 2nd Not using Index 18:40 Implicit Conversion 29:30 DPS 38:00, Bookmark lookup 56:00, Parameter sniffing 1:12:11 (Community service ;-D)

    • @OmarBela12
      @OmarBela12 2 года назад +6

      not all heroes wear a cape... thank you!

  • @pralaysangma8019
    @pralaysangma8019 2 года назад +3

    DPS was a life and career changing event for me and helped me to leap towards my great career journey as a SQL Developer. DPS indeed instilled me the confidence that I could also become a SQLMaestros with a different work experience altogether. Your videos are all worth watching, and missed attending those live sessions. Hope to join those sessions personally soon !
    You are amazing Amit and please continue the great work and continue to transform our lives ! May God continue to bless you and your upcoming sessions.

  • @PepeFuego369
    @PepeFuego369 Год назад +1

    Great video. Keep doing these. I would love to see how you simulate a situation where tempdb is full and a query is still running

  • @alangrichmond-sz2ct
    @alangrichmond-sz2ct 10 месяцев назад

    VERY clear and excellent explanation i use all the queries on my ssms and it worked correctly thanks very much from Texas USA

  • @heezukaa8803
    @heezukaa8803 2 месяца назад

    Nice sir so important topic I'm new to sql server tuning performance though almost i stared used sql for 5months.

  • @bwzffgh7
    @bwzffgh7 2 года назад +4

    Another hidden performance trick is to be careful about using NVARCHAR and VARCHAR interchangeably. I've had instances where query performance was improved by over 80% by simply casting nvarchars to varchar or varchar to nvarchar in the underlying data or subqueries. More often than not, converting early and staying consistent with data types can improve performance. Don't discount the cost of casting between types.

  • @rohit090893
    @rohit090893 Год назад +1

    It was clear and concise explanation. I understood it completely. Thanks for this video.

  • @cwtrain
    @cwtrain 3 года назад +4

    "Not *your* performance problems, your *SQL Server* performance problems."
    Bruh. Why you gotta do me like that? Hehe. Cheers. These videos are excellent.

  • @TellaTrix
    @TellaTrix Год назад

    Really nice explanation on Tunning SQL by Amit

  • @gozinto87
    @gozinto87 3 года назад +1

    This course is brilliant. Thank you sir very much. Greetings from germany

  • @alianwar2433
    @alianwar2433 2 года назад +1

    Really appreciate your contents which is quite Informative. Keep up the good work in future also. Thanks Buddy.

  • @shreyadutta5817
    @shreyadutta5817 Год назад

    Excellent explanation

  • @arunsharma-cb6nn
    @arunsharma-cb6nn Год назад

    this is a good example

  • @SpandhanaKandukuri
    @SpandhanaKandukuri Год назад

    You are just Amazing ...!!! Kudossssssssssss

  • @sujithkumarjack
    @sujithkumarjack 2 года назад +1

    Excellent explanation Keep it up!!

  • @subhanishaik7310
    @subhanishaik7310 2 года назад

    thanks for useful information.....keep post about sql server

  • @SuperWhatusername
    @SuperWhatusername 2 года назад

    very helpful SQLMaestros, Thanks again

  • @Sreedevi2901
    @Sreedevi2901 3 года назад +1

    Very detailed explanation in a very simple way.

  • @sdbjakeer
    @sdbjakeer 4 года назад +1

    Very nice. I've got answers for many of my questions..

  • @robdemarco3722
    @robdemarco3722 3 года назад

    Amit, this is great... Time to build out a zero to hero course :-).... Id help and Id take it after haha. Thank you sir.

  • @vinodkumar-zh1gv
    @vinodkumar-zh1gv 3 года назад +1

    Can you please explain how to use query store with example this very helpful to everyone

  • @juancarlosvasquezgarcia2896
    @juancarlosvasquezgarcia2896 Год назад

    excellent explanation, great contribution, thank you!

  • @dhanashrikarale454
    @dhanashrikarale454 3 года назад

    Very nice looking for this from long time

  • @vinku3666
    @vinku3666 4 года назад +1

    Awesome details covered Thankyou.

  • @abhaysingh4578
    @abhaysingh4578 3 года назад

    Very very Very informative. Thanks a lot. Keep posting some ticks and tips also as a short videos.

  • @tapanb7ind
    @tapanb7ind 3 года назад

    specifically liked the implicit/explicit conversions improving performance

  • @abhayvachhani8088
    @abhayvachhani8088 Год назад

    Thank you it's new to learn

  • @P5toraskar1986
    @P5toraskar1986 2 года назад

    Super session. Great thanks.

  • @higiniofuentes2551
    @higiniofuentes2551 2 года назад

    Thank you for this very useful video!

  • @sanjeetsingh1406
    @sanjeetsingh1406 3 года назад

    Superb explanation.. magical video

  • @rohitjaiswal8116
    @rohitjaiswal8116 Год назад +1

    Thanks 🙏

  • @asharichardson1789
    @asharichardson1789 3 года назад

    Very useful! Thanks for the video

  • @khalilkazi700
    @khalilkazi700 2 года назад

    Very good content. Exceptional way to explain topic

  • @hutchm92
    @hutchm92 8 месяцев назад

    Thank you!

  • @udayakoju07
    @udayakoju07 3 года назад

    Very useful information, thanks for sharing the video

  • @ajirahman5289
    @ajirahman5289 2 года назад

    Awesome very clearly explained

  • @mrunalahire2113
    @mrunalahire2113 4 года назад

    Really informative with all possibilities

  • @abhishek.goel007
    @abhishek.goel007 Год назад

    Sir for recompile, I have a question
    At the same time procedure run if another request comes at that time what will happen?
    Is error occurred?

  • @AtulKumar-lx4iy
    @AtulKumar-lx4iy 2 года назад

    at 11:25 convert...='01/01/2020' is not the same as 14:23's in where clause , here ">=" is being used instead of "=", then why are you saying that the output of the query will be the same ?

  • @heshamabdo6024
    @heshamabdo6024 2 года назад

    Great information thank you

  • @malllikaavvari2543
    @malllikaavvari2543 3 года назад

    Sir it's really nice explanation 👌

  • @SuperWhatusername
    @SuperWhatusername 2 года назад

    Thanks

  • @jegadeesr7213
    @jegadeesr7213 3 года назад +1

    While optimizing T-SQL Queries, in the logical query execution plan, what are the top 3 operators which we should eliminate / optimize?

  • @CalvinPuah
    @CalvinPuah 3 года назад

    Very informative. Thank you very much!

  • @kirankadam2616
    @kirankadam2616 3 года назад

    Nice sir very helpful for me 👍

  • @tvskumar1990
    @tvskumar1990 9 месяцев назад

    How to improve performance of a view where only joins are used without any 'WHERE' available.

  • @nagarajm889
    @nagarajm889 2 года назад +1

    Great video Amit. However, Pinal Deve says index has nothing to do with performance, index is the culprit, delete the indexes if you want to improve performance. Now, I'm confused, two SMEs say two different things. Correct me if I'm wrong

    • @mariopalma5260
      @mariopalma5260 2 года назад

      Do your own testing, Mr Lazy

    • @bwzffgh7
      @bwzffgh7 2 года назад

      Index has nothing to do with performance? The entire point of indexes is performance. Granted, there are scenarios where indexes can hurt performance, but just blankly saying "index has nothing to do with performance" is just wrong.

  • @sunilshinde4595
    @sunilshinde4595 2 года назад

    video is really helpful.but need a guidance , i came across a bug in sql query , which returns incorrect records 1 in 1000 records. how to tackle such issues, request you please make a video of such scenarios.

  • @win-hut41
    @win-hut41 3 года назад

    Yes really useful section all the SQL server developers

  • @DBDilipOnly
    @DBDilipOnly 3 года назад

    Thanks for sharing knowledge

  • @higiniofuentes2551
    @higiniofuentes2551 2 года назад

    In the second case: if you are looking for first name "ken" with the index last name+first name+middle name what would be the solution without creating a new index to be a seek and not scan?

  • @kopalsoni4780
    @kopalsoni4780 4 года назад

    Can anyone explain why 'INCLUDE' is being used to create the index?
    At: 9:30 mins, Line 16-18
    TIA!

  • @ahmedo.975
    @ahmedo.975 3 года назад

    Very toot content very very helpful
    Thanks sir

  • @manmohanmundhraa3087
    @manmohanmundhraa3087 2 года назад

    amazing tips

  • @raghubondalapati1381
    @raghubondalapati1381 3 года назад

    Very helpful!

  • @Shaolin80000
    @Shaolin80000 2 года назад

    In the first example why didn’t you just remove the conversion and put the modified date in the same format as your solution ‘yyyy/mm/DD’?

  • @closed482
    @closed482 3 года назад

    Excellent

  • @zaxxx3
    @zaxxx3 2 года назад

    any idea on how to tune table where column need like '%%'

  • @surbhidwivedi29
    @surbhidwivedi29 2 года назад

    It was awesome

  • @deepakd1453
    @deepakd1453 4 года назад

    Thanks I gained some knowlege

  • @kopalsoni4780
    @kopalsoni4780 4 года назад

    At 54:58, the result of 4th problem's fix gives me same result as with implicit parameterization. Can anyone help me with the reason?

  • @anonymous8633
    @anonymous8633 3 года назад

    Can you share where to find the database to test myself? I found AD2016 but it has TransactionHisotry table!

  • @manishvadher9717
    @manishvadher9717 3 года назад

    I have one query that take too much time.
    here is the explanation that I make
    -> there are 300 columns in one table.
    -> I want to filter on all 300 column with like operator i.e. column_name like '%[search term]%'
    can you help to improve this query

    • @ulmann800
      @ulmann800 3 года назад

      Use reverse(column) and use xxxx% instead of %xxxx

  • @issaceinstein7061
    @issaceinstein7061 3 года назад +2

    Hi Amit, Great Explanation... But i couldn't understand why you change the Business Logic to make SQL Server Faster.? For Example; Take Seek, you change the Business logic to show us what makes scan and seek, good till that... But how to make the Scan converted to Seek without changing the Business Logic.?

    • @reikooters
      @reikooters 2 года назад +2

      He didn't change the business logic. I believe you're talking about what he says at 13:50 (section starts at 11:25) - what he's saying is if you are changing your query to improve the performance, you must make sure that your new query is logically the same - that means, your modified query must always still return exactly the same result that the old query did. Otherwise if you don't, then if this query was a part of some application, then your change has just introduced a bug where the system isn't returning the correct results any more.
      In his example, he is querying a DateTime column for records on a particular date (i.e. from midnight to midnight - the 24 hour period of that date). In the first (bad) query, he achieves this in his WHERE clause by converting the DateTime value to a string which does not include the time component, and compares it to a string of the date he wants to get results for. In the fixed query, the new WHERE clause is selecting rows where the value is >= the date he wants results for AND < the following day.
      The improvement is that he's not converting the column to a string, instead he's keeping the data as a DateTime as it already was. The result is that the query will return results for that entire day, from midnight to midnight. Meaning, his new query is logically the same and returns exactly the same results - that's the part where he says to make sure your modified query is logically the same.
      In the improved query, now SQL Server is able to use the index to find the data much faster (seek - skipping only to the relevant rows in the table) because it isn't doing the string conversion. In the old query it would need to do a scan - it would need to convert the DateTime to a string for every row in the table before it is able to do the string comparison to get the results.

  • @nagasaivelpuri8167
    @nagasaivelpuri8167 2 года назад

    Yes for 38:20

  • @piyushp394
    @piyushp394 3 года назад

    is there any scenario where indexes will reduce the performance? please help me out from this

    • @pizzaiolom
      @pizzaiolom 3 года назад +1

      The more indexes you have on a table, the slower INSERT commands will be since after every insert, EVERY index will be updated.
      That scales really badly if you have a big table with various columns with too many indexes, not to mention it will consume more disk storage.
      Indexes trade insert performance in favor of search performance but its usually not an issue if you use indexes in a smart way (IE not having an index for unused columns and such)

    • @piyushp394
      @piyushp394 3 года назад

      @@pizzaiolom thanks a lot

  • @ryandavies4894
    @ryandavies4894 3 года назад

    Whats the impact of explicit conversions on sargability?

  • @AshishSingh-ep5tt
    @AshishSingh-ep5tt Год назад

    I want to join performance tuning class? Can any body pls help me?

    • @SQLMaestros
      @SQLMaestros  Год назад

      Please drop an email to contact@sqlmaestros.com

  • @rajeshraj-rq4th
    @rajeshraj-rq4th 4 года назад

    Hi Amit, when i execute the below query getting error
    select q.query_hash,
    q.number_of_entries,
    t.text as sample_query,
    p.query_plan as sample_plan
    from (select top 20 query_hash,
    count(*) as number_of_entries,
    min(sql_handle) as sample_sql_handle,
    min(plan_handle) as sample_sql_handle
    from sys.dm_exec_query_stats
    group by query_hash
    having count(*) > 1
    order by count(*) desc) as q
    cross apply sys.dm_exec_sql_text(q.sample_sql_handle) as
    t
    cross apply sys.dm_exec_query_plan(q.sample_sql_handle)
    as p
    Msg 8156, Level 16, State 1, Line 32
    The column 'sample_sql_handle' was specified multiple times for 'q'.
    Please assist me

    • @kopalsoni4780
      @kopalsoni4780 4 года назад

      Problem is in min(plan_handle) as sample_sql_handle. Change it to: , min(plan_handle) as sample_plan_handle

  • @MasterBeastieshow
    @MasterBeastieshow 3 года назад

    good job :)

  • @sanjayschopra5316
    @sanjayschopra5316 2 года назад

    I have implemented Table Partitioning in Azure Sql Server and my table is working fine but sometimes It takes time to retrieve data like in 1 min it retrieves more than 1 lakh records and sometimes i get only 15000 .Please help me on this

  • @ajitraghav8675
    @ajitraghav8675 3 года назад

    28 min has been passed and still have focus ... Nice

  • @ashishvishwakarma2732
    @ashishvishwakarma2732 3 года назад

    My sql server occupying 95% of memory and hence system become slow. How can I fix it. It's a virtual machine and have 60 gb ram. Pls help me.

  • @dhananjayjena6682
    @dhananjayjena6682 2 года назад

    hi

  • @sjcsystems
    @sjcsystems 3 года назад

    Lots of useful content but skipped first 10 minutes or so...

  • @SChaks1
    @SChaks1 2 года назад

    This is very helpful. Thanks a lot!