Differences between Clustered vs Nonclustered Indexes in SQL Server

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ย. 2017
  • 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/
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 59

  • @rondabrown8897
    @rondabrown8897 4 ปีที่แล้ว +16

    Finally someone that explains by using realistic and relate-able scenarios...I actually get it now! Thanks

  • @shaoyizhang
    @shaoyizhang 6 ปีที่แล้ว +13

    The mushroom book example is very helpful. Thank you!

  • @emiliamatrejek5869
    @emiliamatrejek5869 ปีที่แล้ว +1

    I went through all videos on TH-cam regarding this topic and finally that's the one that makes it clear to me. Many thanks!

  • @MrShivanand20
    @MrShivanand20 4 ปีที่แล้ว +13

    finally, a guy on point.. this was perfect!!

  • @cedrics7374
    @cedrics7374 4 ปีที่แล้ว +1

    Thanks man, I was searching for a good explanation of the differences between both, this was perfect!

  • @elisavetkonstantopoulou5386
    @elisavetkonstantopoulou5386 3 ปีที่แล้ว

    Thank you so much for this video! You explained the purpose of both types of indexes perfectly!

  • @carloscepeda8663
    @carloscepeda8663 4 ปีที่แล้ว +3

    Man, you're my hero, I'm not a database guy but this was so perfectly understandable.

  • @robertgaudreau2520
    @robertgaudreau2520 5 ปีที่แล้ว

    Great Bert, very clear explanation on how to use the index.

  • @UmbreonLuv1
    @UmbreonLuv1 2 ปีที่แล้ว

    Incredibly helpful on the difference between the two, thank you so much!

  • @almaguapa-sailboatliveaboa440
    @almaguapa-sailboatliveaboa440 2 ปีที่แล้ว

    Great teacher. Very good to relate an analogy and explain.

  • @galaxywalker2976
    @galaxywalker2976 3 ปีที่แล้ว

    Best explanation on index I have ever watched!

  • @elinanikolopoulou1769
    @elinanikolopoulou1769 ปีที่แล้ว

    Best video i came across so far, for this topic. Great analogies

  • @FlashDark
    @FlashDark 6 ปีที่แล้ว +2

    Great review, thanks!

  • @oljaivkovic6920
    @oljaivkovic6920 4 ปีที่แล้ว

    Really well explained, it helped me a lot!! Thanks!

  • @zzhao463
    @zzhao463 4 ปีที่แล้ว

    fantastically explained!

  • @gladyskiruga9561
    @gladyskiruga9561 3 ปีที่แล้ว

    This was really helpful. Thank you so much.

  • @anshumanbaruah4161
    @anshumanbaruah4161 2 ปีที่แล้ว

    Thanks a lot Bert!

  • @TheGates7
    @TheGates7 3 ปีที่แล้ว

    Maan, this was spot on. Thank YOU

  • @rabes87
    @rabes87 3 ปีที่แล้ว

    Dude, this video was 200x more effective than half of the Microsoft press 70-762 textbook. Thank you sooooo much!!

  • @scottstabbert7966
    @scottstabbert7966 2 ปีที่แล้ว

    Nice. Clear and succinct! Thanks!

  • @andyqueiroz
    @andyqueiroz ปีที่แล้ว

    The better explanation ever found in the hole that are databases

  • @cindyt8152
    @cindyt8152 ปีที่แล้ว

    This is so clear! thanks!

  • @jubinsoni4694
    @jubinsoni4694 4 ปีที่แล้ว

    Great Explanation

  • @Vasanthkumar-cm8he
    @Vasanthkumar-cm8he 4 ปีที่แล้ว

    Great work... solves my basic doubts

  • @BoxerDogs
    @BoxerDogs 3 ปีที่แล้ว +3

    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?

  • @sujinsnair
    @sujinsnair 5 ปีที่แล้ว

    Very helpful, Thank you

  • @yoanadimitrova8760
    @yoanadimitrova8760 6 ปีที่แล้ว +3

    Thanks, blue eyes! That was helpful. Can you do a video on ColumnStore Indexes, please?

  • @nikjojo
    @nikjojo 8 หลายเดือนก่อน

    4:55 easily explained

  • @gotchihaeyo1825
    @gotchihaeyo1825 ปีที่แล้ว

    At 7:40, I finally understood the nonclustered index. Thanks.

  • @aniketdeshmane6569
    @aniketdeshmane6569 ปีที่แล้ว +1

    THANKYOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You made this so much easy

  • @lucianavasiloiei7864
    @lucianavasiloiei7864 ปีที่แล้ว

    Thank you!

  • @Genovia816
    @Genovia816 3 ปีที่แล้ว

    Super Helpful, Thanks

  • @shreyalande7573
    @shreyalande7573 3 ปีที่แล้ว

    Outstanding!!!!

  • @fadimichael9788
    @fadimichael9788 6 ปีที่แล้ว +2

    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.

  • @MrNessuno31
    @MrNessuno31 3 ปีที่แล้ว

    Absolutely brilliant explanation, thanks Bert!

  • @alexanderkorotkoff2639
    @alexanderkorotkoff2639 2 ปีที่แล้ว

    Thank you

  • @hnasr
    @hnasr 4 ปีที่แล้ว

    well said! great video

  • @katdareshruti
    @katdareshruti 3 ปีที่แล้ว

    Thank you, thank you, thank you

  • @samdatta9163
    @samdatta9163 4 ปีที่แล้ว

    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?

  • @muchwow3839
    @muchwow3839 3 ปีที่แล้ว

    FINALLY! An explanation I actually understand lol

  • @mehdizeynalov1062
    @mehdizeynalov1062 ปีที่แล้ว

    Thank you very much, would be good if some examples were added, maybe it's already there in next videos

  • @BoxerDogs
    @BoxerDogs 3 ปีที่แล้ว

    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)

  • @MasterCamus
    @MasterCamus 4 ปีที่แล้ว

    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?

  • @trishlasaxena9970
    @trishlasaxena9970 3 หลายเดือนก่อน

    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.

  • @kundangaikwad8941
    @kundangaikwad8941 4 ปีที่แล้ว

    Nice explanation..! create more videos on others indexes

  • @aaronwhager
    @aaronwhager 5 ปีที่แล้ว

    Very helpful, thanks.

    • @aaronwhager
      @aaronwhager 5 ปีที่แล้ว

      @@DataWithBert Yea man, I just cut a 20+ min query down to 6 seconds by creating a proper non-clustered index! Wow!

  • @kirankumarkommalapudi9947
    @kirankumarkommalapudi9947 6 ปีที่แล้ว

    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..

  • @seanpaulson9098
    @seanpaulson9098 6 หลายเดือนก่อน

    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?

  • @BijouBakson
    @BijouBakson ปีที่แล้ว

    thank u

  • @snake1625b
    @snake1625b 2 ปีที่แล้ว

    with the cheap cost of storage, is the extra space a unclustered index really that much of a downside?

  • @markmatheney8631
    @markmatheney8631 ปีที่แล้ว

    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?

  • @camiloatencio3662
    @camiloatencio3662 2 ปีที่แล้ว

    SCREAMING AT THE INTRODUCTION

  • @ryanbiztech9181
    @ryanbiztech9181 3 ปีที่แล้ว

    You remind me of the protagonist of Inception

  • @rahulsalunkhe8364
    @rahulsalunkhe8364 4 ปีที่แล้ว +1

    Hi please next time please please use some animation or drawing...
    That will help a lot...

    • @richardplester
      @richardplester 4 ปีที่แล้ว

      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

    • @rahulsalunkhe8364
      @rahulsalunkhe8364 4 ปีที่แล้ว

      @@richardplester Hi, at least you can draw on board, C its for better understanding for me..

  • @anitha9006
    @anitha9006 ปีที่แล้ว +1

    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

  • @vittalshanbag2892
    @vittalshanbag2892 4 ปีที่แล้ว

    Hai sir,Pls provide me with demonstratation of clustered and non clustered index with small examples...
    Thank you sir