Differences between Clustered vs Nonclustered Indexes in SQL Server

2017 ж. 25 Қыр.
53 311 Рет қаралды

Should you use a clustered or a nonclustered index?
When starting out with SQL, you might intuitively know that you should add an index to a table, but you might not be sure what kind of index to add.
In this video we go over the basics of clustered and nonclustered indexes to help you get through index choice paralysis.
Blog post with example queries:
bertwagner.com/2017/09/26/clu...
Follow me on Twitter:
/ bertwagner
Want to receive my latest weekly blog posts and videos in your inbox? Sign up for the newsletter here: upscri.be/c77fc8/

Пікірлер
  • Finally someone that explains by using realistic and relate-able scenarios...I actually get it now! Thanks

    @rondabrown8897@rondabrown88974 жыл бұрын
  • The mushroom book example is very helpful. Thank you!

    @shaoyizhang@shaoyizhang6 жыл бұрын
  • I went through all videos on KZhead regarding this topic and finally that's the one that makes it clear to me. Many thanks!

    @emiliamatrejek5869@emiliamatrejek5869 Жыл бұрын
  • Dude, this video was 200x more effective than half of the Microsoft press 70-762 textbook. Thank you sooooo much!!

    @rabes87@rabes873 жыл бұрын
  • The better explanation ever found in the hole that are databases

    @andyqueiroz@andyqueiroz Жыл бұрын
  • Man, you're my hero, I'm not a database guy but this was so perfectly understandable.

    @carloscepeda8663@carloscepeda86634 жыл бұрын
  • finally, a guy on point.. this was perfect!!

    @MrShivanand20@MrShivanand204 жыл бұрын
  • Thanks man, I was searching for a good explanation of the differences between both, this was perfect!

    @cedrics7374@cedrics73745 жыл бұрын
  • At 7:40, I finally understood the nonclustered index. Thanks.

    @gotchihaeyo1825@gotchihaeyo1825 Жыл бұрын
  • Great Bert, very clear explanation on how to use the index.

    @robertgaudreau2520@robertgaudreau25205 жыл бұрын
  • Thank you so much for this video! You explained the purpose of both types of indexes perfectly!

    @elisavetkonstantopoulou5386@elisavetkonstantopoulou53863 жыл бұрын
  • Best explanation on index I have ever watched!

    @galaxywalker2976@galaxywalker29763 жыл бұрын
  • Incredibly helpful on the difference between the two, thank you so much!

    @UmbreonLuv1@UmbreonLuv12 жыл бұрын
  • Best video i came across so far, for this topic. Great analogies

    @elinanikolopoulou1769@elinanikolopoulou1769 Жыл бұрын
  • Do you have a video that explains the differences between a table scan, index scan and an index seek and when SSMS will use each of these? If not, would you consider doing a video about this?

    @BoxerDogs@BoxerDogs3 жыл бұрын
  • Great teacher. Very good to relate an analogy and explain.

    @almaguapa-sailboatliveaboa440@almaguapa-sailboatliveaboa4402 жыл бұрын
  • Really well explained, it helped me a lot!! Thanks!

    @oljaivkovic6920@oljaivkovic69204 жыл бұрын
  • Great work... solves my basic doubts

    @Vasanthkumar-cm8he@Vasanthkumar-cm8he4 жыл бұрын
  • Great review, thanks!

    @FlashDark@FlashDark6 жыл бұрын
  • This was really helpful. Thank you so much.

    @gladyskiruga9561@gladyskiruga95613 жыл бұрын
  • Nice. Clear and succinct! Thanks!

    @scottstabbert7966@scottstabbert79662 жыл бұрын
  • fantastically explained!

    @zzhao463@zzhao4634 жыл бұрын
  • Thanks, blue eyes! That was helpful. Can you do a video on ColumnStore Indexes, please?

    @yoanadimitrova8760@yoanadimitrova87606 жыл бұрын
  • This is so clear! thanks!

    @cindyt8152@cindyt8152 Жыл бұрын
  • Thanks a lot Bert!

    @anshumanbaruah4161@anshumanbaruah41612 жыл бұрын
  • Maan, this was spot on. Thank YOU

    @TheGates7@TheGates73 жыл бұрын
  • Absolutely brilliant explanation, thanks Bert!

    @MrNessuno31@MrNessuno313 жыл бұрын
  • THANKYOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You made this so much easy

    @aniketdeshmane6569@aniketdeshmane6569 Жыл бұрын
  • A very good video, only part is the example of the clustered index, in my opinion, should be a phone book or dictionary instead of textbook content as the clustered is physically sort/ordered the data, this example very much applied on the no-clustered index. Thanks.

    @fadimichael9788@fadimichael97886 жыл бұрын
  • Great Explanation

    @jubinsoni4694@jubinsoni46944 жыл бұрын
  • Very helpful, Thank you

    @sujinsnair@sujinsnair5 жыл бұрын
  • Super Helpful, Thanks

    @Genovia816@Genovia8163 жыл бұрын
  • Thank you very much, would be good if some examples were added, maybe it's already there in next videos

    @mehdizeynalov1062@mehdizeynalov1062 Жыл бұрын
  • At 6:35 you give an analogy about a nonclustered index and a clustered index. If I understand what you are saying, are the following statements true: - A nonclustered index is like an index at the back of a book, with page numbers (each page number is like a row identifier) - A clustered Index is like an index at the back of a book, but no pages numbers (which would seem odd for a book to have)

    @BoxerDogs@BoxerDogs3 жыл бұрын
  • FINALLY! An explanation I actually understand lol

    @muchwow3839@muchwow38393 жыл бұрын
  • Outstanding!!!!

    @shreyalande7573@shreyalande75733 жыл бұрын
  • So for a report that runs from a SP with a couple of temp tables. Is it better to add cluster index after filling the tables?

    @MasterCamus@MasterCamus4 жыл бұрын
  • Very helpful, thanks.

    @aaronwhager@aaronwhager5 жыл бұрын
    • @@DataWithBert Yea man, I just cut a 20+ min query down to 6 seconds by creating a proper non-clustered index! Wow!

      @aaronwhager@aaronwhager5 жыл бұрын
  • Thank you!

    @lucianavasiloiei7864@lucianavasiloiei7864 Жыл бұрын
  • Nice explanation..! create more videos on others indexes

    @kundangaikwad8941@kundangaikwad89415 жыл бұрын
  • Good video.it helped me a lot to understand clustered and non clustered index.can u plztell me that ..if i create unique key does it create a non clusterd index or clustred?

    @samdatta9163@samdatta91634 жыл бұрын
  • Thank you, thank you, thank you

    @katdareshruti@katdareshruti3 жыл бұрын
  • this video is really helpful . I have a doubt. If I have defined clustered and non clustered index and we are inserting new row, it will add the newly added row in specific position and shift other rows as per clusterd index. So, how non clustered index is getting benefitted here on inserting new rows. And is that possible to have table without any clustered index.

    @trishlasaxena9970@trishlasaxena99703 ай бұрын
  • Nice video.. but my understanding was table of contents also like non clusterd indexes not the clusterd index. Because contents also have just the address of the details in that book. Please correct me if I am wrong. In the video @5.10 min this info mentioned..

    @kirankumarkommalapudi9947@kirankumarkommalapudi99476 жыл бұрын
  • Thank you

    @alexanderkorotkoff2639@alexanderkorotkoff26392 жыл бұрын
  • 4:05 im confused why a insert would be so slow in this situation. Can clustered indexas not be sorted by some sort of tree?

    @seanpaulson9098@seanpaulson90986 ай бұрын
  • well said! great video

    @hnasr@hnasr4 жыл бұрын
  • thank u

    @BijouBakson@BijouBakson Жыл бұрын
  • 4:55 easily explained

    @nikjojo@nikjojo8 ай бұрын
  • with the cheap cost of storage, is the extra space a unclustered index really that much of a downside?

    @snake1625b@snake1625b2 жыл бұрын
  • Ummm, regarding multiple nonclustered indexes. You made a comment that occasionally you have added a nonclustered index only to see other nonclustered indexes take a performance hit. If each nonclustered index is "independent", how could it effect the performance of other nonclustered indexes? When doing a query, doesn't SQL pick the most optimal index, and use that one? In other words, I suppose that it SQL "thought" a new nonclustered index was "faster" and used it, I suppose that would be possible, but wouldn't that we a problem with SQL?

    @markmatheney8631@markmatheney8631 Жыл бұрын
  • SCREAMING AT THE INTRODUCTION

    @camiloatencio3662@camiloatencio36622 жыл бұрын
  • You remind me of the protagonist of Inception

    @ryanbiztech9181@ryanbiztech91813 жыл бұрын
  • Hi please next time please please use some animation or drawing... That will help a lot...

    @rahulsalunkhe8364@rahulsalunkhe83644 жыл бұрын
    • Wow the mushroom book analogy wasn't enough? Just mentally picture a table of contents and an index for a book, failing that rewatch where he flashes those parts of the book :) I'd rather Bert spends time banging out quality info vids rather than labouring on pretty but unnecessary graphics

      @richardplester@richardplester4 жыл бұрын
    • @@richardplester Hi, at least you can draw on board, C its for better understanding for me..

      @rahulsalunkhe8364@rahulsalunkhe83644 жыл бұрын
  • Indexes should not be used 1)on small tables 2)tables that have large batch updates or insert operations 3)not be used on tables with high number of null values4)columns that are frequently manipulated

    @anitha9006@anitha9006 Жыл бұрын
  • Hai sir,Pls provide me with demonstratation of clustered and non clustered index with small examples... Thank you sir

    @vittalshanbag2892@vittalshanbag28924 жыл бұрын
KZhead