Nonclustered Primary Key - SQL in Sixty Seconds 119

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

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

    Awesome explanation of things that we think are only capable of be done in a single way, because it is the default. But there are multiple reasons and explanations for alternative ways of implementation for each scenario. Thanks, Pinal!

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

    Great video and demonstration.
    Thanks pinal 🙂👍

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

    Thanks Pinal...this clearly clears the misconception for lot of people

  • @JagteRah0
    @JagteRah0 4 ปีที่แล้ว +2

    This was very interesting Pinal, thanks for the Demo.

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

    Very nice, You are always suggesting good tricks..

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

    Love your info Pinal, thanks a bunch!

  • @nilesh-gule
    @nilesh-gule 4 ปีที่แล้ว +1

    Great video Pinal Dave sir. Please create a video on columnstore clustered index

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

      I already have one on rh8s blog. Let me create one more soon.

  • @a.useronly2266
    @a.useronly2266 2 ปีที่แล้ว +1

    Thanks a lot sir👌🏻👍🏻

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

    But which is the best approach? Clustered or NonClustered Primary Key for huge data volumes?

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

      I wish I could answer that one. This one is indeed difficult to answer without doing the test.

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

    Thanks a lot, greetings from Mexico.

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

      Mucho Gracias

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

      @@PinalDaveSQLAuthorityThanks a lot for the videos, are great...In Mexico we use a slang word for great, we say "chingón" to mean something is great..Your videos are "chingones".

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

      @@israel1919 You made my day amigo!

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

    Very informative video Pinal, can you please make video on how to update a table with 6 billion rows having clustered column store index on that and non clustered primary key.

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

    sir any video how function impact query performance in select or in where clause .

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

    Good information. Thanks you so much.

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

    Great insight. Thank you Dev.
    Have a question, If I don’t create clustered index and create a non clustered index on a table then what will be the base of non clustered index?
    As per my knowledge the leaf node of non clustered would be based on clustered index row ids. Is it not true?

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

    Thanks Pinal, very useful!

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

      Glad that you liked it. I am so happy that you watch my videos.

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

    Thanks sir...Very informative... 🙏🙏

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

    Thanks sir for this video.
    i have one doubt ,can you create one video for difference between
    single column index vs multicolumn index.

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

      Sure here is one...th-cam.com/video/pak2cPE1Y-g/w-d-xo.html

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

    Hi Pinal Dave iam reading and following your block from last 5 years if possible put detailed explanation of execution plan complete operators

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

    Hi Sir, I am having following problem one of the stored procedure.. The stored procedure is calling through SSIS package and this package is running in SQL Server Agent job daily based on schedule time.. My problem is After completing the job.. In recent month few data points are not loading and rest of the data points I can able to see the recent month data points. . if i run same Stored procedure in SSMS i can see all the data points .. not able to figure out what is the issue .. could you please let me know what could be the reason in this scenario..looking for your valuable input..Thanks in advance.. version of the SQL Server is 2012

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

    Thanks Pinal for useful info

  • @a.useronly2266
    @a.useronly2266 2 ปีที่แล้ว +1

    Sir one question, can we create noncluster columnstore index on primary key and drop cluster index on same column, and please tell me if this will help performance while table having 1.5 billion rows in it

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

      I prefer to have a clustered index on table as it usually helps multifold with performance.

    • @a.useronly2266
      @a.useronly2266 2 ปีที่แล้ว

      @@PinalDaveSQLAuthority ok 👍🏻 thanks sir

  • @ayushanshuman5383
    @ayushanshuman5383 4 ปีที่แล้ว +2

    What's the use of primary key with non clustered index, as we can't insert duplicate data into non clustered primary key

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  4 ปีที่แล้ว +2

      It is very common use case in datawarehouse.
      Also cluster index key is repeated in nonclustered index so sometimes it is important to have them different.

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

      Oho.. understand ur point... and ur vedio share greate information.. thanks..

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

    Thanks Very easy to understand

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

    What scenearies would be useful to have a PK non-clustered?

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

      When you want clustered index some other columns.

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

      @@PinalDaveSQLAuthorityFor child tables, is it a good idea to create the FK against the master table clustered and the PK non clustered? Could this work better against locks/deadlocks?

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

    Very interesting and useful 👍

  • @deepakk26
    @deepakk26 4 ปีที่แล้ว +2

    Sir Thanks for clearing the biggest lie of my life for SQL. Just wondering, why would someone use 3rd scenario from the video? How is it going to help?

    • @PinalDaveSQLAuthority
      @PinalDaveSQLAuthority  4 ปีที่แล้ว +2

      It is very common in datawarehouse. They want clustering index to be smaller.

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

    Hello Sir,
    Thank you for the video. I learned lot from you.
    I have table with records of 45lakhs so can I used Clustered index or Non clustered index. When I used a non clustered index on composite key , it works very fast as compared to clustered index. please let me know your thought sir.

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

      It is difficult to answer without providing all the necessary details like schema, data, statistics, etc.

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

      Sir i will share details with u.

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

    hi , with a Primary key / Non-clustered index, does it mean Duplicate is allowed on the Primary key field ?

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

    pk noncluster seems very useful with partitioned tables, what do you think Pinal Dave?

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

      Very difficult to say without looking into the whole partitioning scheme. However, in general terms yes, I agree.

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

      @@PinalDaveSQLAuthority thanks for your time reading the comments 🙌

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

    Hi pinal what is the birth place of index / data page? (buffer or data file?)

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

    thanks for the demo

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

    Strictly speaking sql adds hidden data and sorts by that. I’ve had loads of tables where the clustered index is not the primary key, but it’s always worth having a clustered index.

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

    Good one. Thanks.

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

    Thank you

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

    Awesome trick

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

    Very intresting....

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

    That is really interesting