Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Why would you ever designate a primary key as non-clustered?

Why would you ever designate a primary key as non-clustered?

Scheduled Pinned Locked Moved Database
comquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #1

    Any ideas? I'm coming across this, and it makes no sense to me. Marc

    Thyme In The Country Interacx My Blog

    S A E 3 Replies Last reply
    0
    • M Marc Clifton

      Any ideas? I'm coming across this, and it makes no sense to me. Marc

      Thyme In The Country Interacx My Blog

      S Offline
      S Offline
      SomeGuyThatIsMe
      wrote on last edited by
      #2

      i wasnt aware that you could create a PK that wasnt clustered, i thought they were all clustered indexes.

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      A 1 Reply Last reply
      0
      • S SomeGuyThatIsMe

        i wasnt aware that you could create a PK that wasnt clustered, i thought they were all clustered indexes.

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        A Offline
        A Offline
        Alsvha
        wrote on last edited by
        #3

        In SQL Server they are clustered as default. But you can make then non-clustered and use the clustered index for yourself.

        --------------------------- Blogging about SQL, Technology and many other things

        modified on Friday, June 20, 2008 12:20 AM

        S 1 Reply Last reply
        0
        • M Marc Clifton

          Any ideas? I'm coming across this, and it makes no sense to me. Marc

          Thyme In The Country Interacx My Blog

          A Offline
          A Offline
          Alsvha
          wrote on last edited by
          #4

          As I'm sure you know - it depends on your database design and how you access the tables. I think they are made this way by default to ensure at least some "workable" indexes for default databases from people who haven't looked too much into indexation. Because if you mainly access a table via - for example - foreign keys and extract 2 or 3 specific rows of data, it makes sense - to me at least :D - to make that your clustered index. Also if your PK is primarily an identity or similar number which mattes little then I would also say it makes sense to keep that index non-clustered, because it usually means you'll access data not in the index anyway and the benefits of the clustered index diminishes. However if your primary key consists of "relevant data" and you need to access this data only - and often - then it is beneficial to have it as clustered. In my opinion - it is as all things with databases, a case-by-case evaluation, but as mention first - my main guess is that it is made to simply have some "default" clustered indexes for the default databases, and those who know what they are doing will evaluate whether it is a beneficial index and change it if not anyway.

          --------------------------- Blogging about SQL, Technology and many other things

          1 Reply Last reply
          0
          • A Alsvha

            In SQL Server they are clustered as default. But you can make then non-clustered and use the clustered index for yourself.

            --------------------------- Blogging about SQL, Technology and many other things

            modified on Friday, June 20, 2008 12:20 AM

            S Offline
            S Offline
            SomeGuyThatIsMe
            wrote on last edited by
            #5

            makes sense...thanks, but i'm going to assume they arent doing that in the table Marc's looking at.

            Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

            1 Reply Last reply
            0
            • M Marc Clifton

              Any ideas? I'm coming across this, and it makes no sense to me. Marc

              Thyme In The Country Interacx My Blog

              E Offline
              E Offline
              econner
              wrote on last edited by
              #6

              One instance I have seen is when using a GUID as a PK field.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups