Performance Challenge - Write Efficient Query - SQL in Sixty Seconds 140

Поделиться
HTML-код
  • Опубликовано: 21 дек 2024

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

  • @Dawar1230
    @Dawar1230 5 месяцев назад +1

    Pinal Dave is truly remarkable for his deep expertise and practical insights in SQL Server.

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

    Have got immense help from you Pinal for the last 15 years.. You are an institution. Take my sincere regards.

  • @jinanchehab7715
    @jinanchehab7715 4 года назад +9

    Pinal, you are an SQL Wizard! Thank you for the continuous SQL video learning series . Great work. You are my first reference when I have to troubleshoot my SQL Queries performance .

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

    Just got this video from suggestion, and my conclusion is u are superb sql man..

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

    This is Gold! Thank you! It would show the most efficient query, even the query itself is written very inefficiently from a solution point of view!

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

    I am really happy this SqL Authority blog is now on videos. Than reading the blogs, it's more clear Pinal. Thank you so much.

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

    Last several yours we are reading your articles.. you are doing asume work .... keep it up please

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

    Well presented Pinal.
    SQLAuthority.com has been a generous source of information and a rock solid point to fallback when we have a tuff SQL times.
    Big fan

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

    Never seen anyone explaining sql with so much of excitement! Thank you Pinal Dave!!

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

    It's evident that all three queries are good in the context of I/O, CPU, and plan percentage. Sometimes we won't get all the good measures in a single query and for that reason, we say it as performance 'tuning'.

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

    Thats why you are genius sir, and because of this many of us following you though have other bloggers

  • @SaifulIslam-cn1ii
    @SaifulIslam-cn1ii 2 года назад +1

    Day by day I am learning a lot from you sir. Thank you so much for teaching all of us. God bless you.

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

    The web is full of answers to my SQL questions. Your website is my "go-to" default getting the right answer.

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

    Really helpful video for SQL query performance PoV. Thanks a ton SQL genious Pinal

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

    I am your fan for many years. Thank you and god bless you. I wish I could give you one thousand likes.

  • @rgulamhussein
    @rgulamhussein 4 года назад +5

    A real eye opener Pinal! Thank you! I always thought that I/O would automatically improve when the execution plan is optimized. I've relied on your articles a lot over the years. Thank you!

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

    Brilliant article! STATISTICS TIME AND IO are my new best friends :-)

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

    I am your fan brother and following you from more than 10 year on your blog.. I learnt a lot from your blogs.. keep doing brother

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

    Thanks Pinal, I've definitely picked up a lot from you over the last 10-12 years, but still not a sql expert as I spend a little more time in frontend or backend web code. Every time I watch one your videos or read a blog post, I always come away finding out how much I don't know. Good stuff as always.

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

    Thank you for a real example. This often happens to me since there are several developers and each tries it's own method. Usually have IO issues so I'm going to check the Rank option.

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

    Hi..you are 60 secs videos are very helpful in our day-to-day work. Thanks for your continuous teaching.

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

    your blogs are very help full for the DBAs great effort

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

    Thanks, appreciate it. My first thought was #2 as that's normally the fastest (and the one I would use).

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

    I really watched your video first time. really a fan of your Craft Video amazing. before that, i have read your articles much time but I really like video learning. i really follow in my start Kudvancat and Shiv Prasad and now in SQL you are the master and your way of presenting is amazing.

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

    Very productive video in 60 sec. I wonder if every valuable learning were at that time.

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

    Thanks Pinal, very clearly explained.

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

    Good job! Thank you!
    Actually clients want quick executing query, but as a developer I prefer query that takes low server resources.

  • @Bruellhusten123
    @Bruellhusten123 10 месяцев назад +1

    Great video! Very informative.
    Your blog was a great source of information many years ago for me when I had to deal with a super complex DB System at my old work. Keep up the great work!
    My gut feeling was right, based on query complexity TOP(1) combined with UNION.

  • @MUHAMMADALI-nb6tm
    @MUHAMMADALI-nb6tm 3 года назад +1

    Brilliant!! Those three factors are has to be in considerations

  • @धीरज-ठ4ह
    @धीरज-ठ4ह 3 года назад +1

    bossman, you're a genius. thank you for this video.

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

    You totally rock! The nice thing about your videos....the average programmer-wannabe should be able to understand them. If they don't, banish them to the SQL Blackhole!

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

    Thank you for a very clear and informative video. Exactly what I needed.

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

    Thanks pinal. It's very useful for me..

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

    Again great video Sir. the query itself is written very efficiently and informative from a solution . Thanks

  • @deepakkumar-fv8us
    @deepakkumar-fv8us 3 года назад +1

    Thanks Pinal for your valuable series. Really learning a lot through these!!

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

    Good explanation thank you pinal Dave sir

  • @FrancisH-piano
    @FrancisH-piano 4 года назад +1

    Well done. The format of this vide is great and the real example is helpful and realistic. Your discussion of what constitutes "efficiency" is well explained. Thanks Pinal Great job

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

    Great explanation. Keep it up and wait for another more than 60 second video. 👍👍

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

    Your videos are great, informative and entertaining! I had guessed option 2, I have seen good performance from TOP operator like that in a number of cases.

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

    Wow..Nicely explained.
    Thanks a lot sir🙏🙏

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

    Thanks, Pinal for the clear explanation. Can you share the final query that you have rewritten the 3rd query using the 2nd method as u mentioned @5:18

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

    "SQL in the sixty seconds" Its Great😊Thank you

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

    I love this 60 sec idea. Wonderful!!!

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

    cool examples and explanation. thanks

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

    This is pure gold Pinal...Thanks

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

    Thank you. Your videos are really helpful. Great work.

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

    I had guessed the third query but had failed to realize that we were then using the results of the aggregate to interrogate the table a second time.
    One key point to remember is if the query might be executed multiple times. Sometimes, the optimizer can cache the results. This is particularly important when the query may be processed for multiple requests. This might occur on a website for example. I always like to understand the usage that will happen, so I can test what happens if the query is executed with different filter criteria for multiple requests (or maybe the same...). I have found that some compatible queries might be slower for the first execution, but subsequent queries cause the original (slower query) to be faster. (A key reason to use procedures/functions and make them deterministic...[Will not execute multiple times if passed the same parms.)

  • @parashuramakulakarni5073
    @parashuramakulakarni5073 4 года назад +5

    Thank you - could you do a video on result sets and how it works in join conditions?

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

    Should be required viewing for all SQL developers (and half of the SQL Admins I've worked with).

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

    Thanks, I always enjoy your videos and they are interesting too.

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

    Another great video Pinal. I didn't even guess the most efficient query as I thought it would depend on what kind of efficiency :) Very informative. Thanks.

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

    Thanks Pinal for these wonderful videos.

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

    Hi Pinal..List out the recommended videos in the discription as well..
    Thanks🙏.. your videos are really helpful

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

    Hello Pinal
    Could you please explain what do we need to check if we are to perform a DB health check? Also, How do I reduce the I/O bottle neck?

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

      Many of the video talks about it. You can also follow sqlauthority.com where I write on the same topic.

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

    Keep up the good work Pinal!

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

    Great nicely explained

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

    Thank you Pinal for sharing.

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

    You are an SQL king!

  • @mosheritterman3472
    @mosheritterman3472 4 года назад +6

    Great video!
    I thought that cost is related to time and IO. I'm now at a loss as to what exactly the query cost is for. Can you explain what the benefit of an optimal execution plan (i.e. query cost) is if IO and time are worse in the first query? Meaning, what is SQL server using to calculate the query cost and what benefit do I have from using the query with the best execution plan?

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  4 года назад +5

      Yeah they are not linearly connected. I will create future video on this topic.

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

      @@PinalDaveSQLAuthority I was wondering when you might do this video. I really would like to understand this. Thanks

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

      @@mosheritterman3472 I usually cover this in my training so I will have to carve out this one from it. I will plan it very soon.

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

    Real internet Gold! :) Thanks Pinal!

  • @SatyamKumar-sg2wr
    @SatyamKumar-sg2wr 2 года назад +1

    Could you please create such video for Azure Data warehouse(Dedicated SQL Pool) . There optimization concept varies from normal sql database

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

    Sir can you have an example of Indexing. (e.g. When to use clustered and non-clustered index?) and also the best practice on how to apply it.

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

      Clustered indexes are good to avoid forwarded records. Watch this video blog.sqlauthority.com/2021/02/15/forwarded-records-and-performance-sql-in-sixty-seconds-155/

  • @ManojSingh-sp1tz
    @ManojSingh-sp1tz 4 года назад +1

    Nice sir wounded full explanation

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

    nice video.!! thanks
    can you do more video for parameter sniffing ? what is parameter sniffing and how to handle it...

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

    "SQL in the sixty seconds" I love it!! 😊Thanks, Pinal!

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

    It will be helpful if you can explain with reason difference in performance for each query.

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

    I am quite new to SQL. If I want to know more about what is page reads and how Statistics work then any guide ?

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

    This was a great video... excelent... thanks master Jedi!

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

    Thanks you for giving such information..

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

    @Pinal, I am a bit confused, can you please clarify again here?
    Are you telling that the performance check depends on the client's needs? either he is interested on IO or Time, developer need to check with him on it?.

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

    Thanks once more, for sharing this knowledge

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

    Thankyou, very nice session

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

    Mr. Bond you are savior. Really useful info...could you please also know in terms of query efficiency what metric stand out the most IO read or Elapsed Time taken query to execute. Shouldn't execution plan give result based on IO read and Elapsed Time?

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

      Execution plan has different purpose, it shows how the query is executed.

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

    Nice video, Please make a video on how to write a query interms of Excecution plan, CPU Usage and Time. Is using subquery reduces the performance ?, Joins vs using subqueries. Is using IN clause makes query slower ? If yes any other alternatives ?

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

      Check other videos on this channel. Many of the topics are already covered..

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

    Thanks for simplifying the things for better understanding to everyone. I think, the "Scan count" in IO Stats didn't considered in this video, is that by intention?

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

    Excellent sir👍

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

    Thank you for all this. But how do we know there is a problem with the execution plan or IO or execution time.

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

      That analysis you can do via SQL Wait Statistics. If you have subscribed to SQLAuthority.com newsletter, you may have received the script. The link is in the video's blog.

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

    Great video!!!

  • @SunilKumar-z1x4j
    @SunilKumar-z1x4j Год назад +1

    All i can say is amazing.

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

    Hi Pinal, I am big fan of your SQL in sizty seconds short videos series..I am desparately looking for a video from your side about 2 scenarios which is mostly asked in Interviews :

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

    Thank you sir, very well explained.
    Sir can you please create a course for Performance tuning and optimization.

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

    Awesome sir, ur like SQL encyclopaedia.. I just had a chance to watch ur presentation to craft … It’s really surprised me … Can you please do videos on performance tunings in procs & Indexes … Thanks a lot in advance 🙏🙏🙏

  • @AshishPatel-nw9re
    @AshishPatel-nw9re 4 года назад +1

    Can we create index for timestamp column? If Data is continuously insert into database with timestamp column.

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

      You can create an index on any column, you should first check the performance of your query with the methods explained in the video and decide if the index is good or bad.

    • @AshishPatel-nw9re
      @AshishPatel-nw9re 4 года назад

      @@PinalDaveSQLAuthority thankyou for your response

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

    Thanks for the video. Great job!

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

    Always great content and delivered with a smile. Thanks for making SQL more interesting for us all.

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

    Hi PinalDev,
    Thanks for your explanation.
    can you please explain how the 2nd query works faster when the io operation takes more time than 3rd query. Are io operation and executive time not directly proportional??

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

      They are not directly proportional. There are many other aspects as well when it is about query performance.

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

      @@PinalDaveSQLAuthority thanks , I am expecting those things in the up coming videos 😊

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

    can you share same things with huge data, indexes, and caching

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

    Very best Sir

  • @cesare.hijarsantamaria4867
    @cesare.hijarsantamaria4867 Год назад

    Great video. Do you have any URL or UDEMY course about SQL Tuning on SQL Server and SQL Server Instance-Server Tuning also? Please let me know.

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

    Efficiency of Execution plan versus efficiency on time how is this different? Could you pls explain

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

      They are different parameters. You should tune query for the one which is the most appropriate.

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

      @@PinalDaveSQLAuthority I mean, isn't that the best execution plan will ensure quick response?

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

      @@anantharamakrishnan19 no, it is not true. That is what this video is talking about.

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

    I believe Window Function, because I believe it only requires one table scan.

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

    You are great !

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

    Hello Pinal how can we get the info of deadlock situation happened in the past

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

      Past details are hard to get. You can configure extended events for the future events.

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

    I am oracle dba but I like your videos :)

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

    Wow..great video...thanks!!

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

    Hi Do you have any idea about OBIEE regarding istallation

  • @ManojSingh-sp1tz
    @ManojSingh-sp1tz 4 года назад +1

    Please can u explain query optimization

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

      I have done already few videos on this topic. I will create more as I go.

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

    Hello sir I have one sql stored procedure and it is almost taking 3 minutes to get 75K records. Can we do improvement this SP? Please provide your inputs.

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

    Hi Pinal, Great Insight, and I just want to share my thought process in selecting 2 nd query as my answer before watching the whole video
    I thought aggregation and Window introduce sorting which is extra work to perform, so eliminated those two and opted for 2.

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

    In the second query why not just skip the subquery and UNION the TOP 1's? Wouldn't that perform best? Also, would EXISTS improve the performance or execution plans in this?
    I've never thought of writing a query like that to get the top/bottom result. I'll have to keep this in mind.

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

      Absolutely, that can be done too! However, it will not impact performance, which I have tried before. Thanks for your kind comment.