Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing PK from non-clustered to clustered
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01637980
Message ID:
01638017
Vues:
42
>>>>Based on that, you *should be* ok to make it a clustered index. One thing I haven't seen mentioned here. A clustered index is really a physical storing of the data in index order. You can insert, but it could mean rewriting a large portion of data.
>>>>
>>>>>The ID is an Identity column. If a user creates an order it is (ID) automatically set to the next ID sequential number. If user does not save the newly created record, the "missed" number will never be inserted.
>>>
>>>Exactly - if the definition of the clustered index represents a level of randomness when inserting new rows, you potentially wind up with index fragmentation, which can really impact performance.
>>
>>I understand what you are saying. But in the case that I am describing - PK column being an Identity and INT type - is there a downside to making the PK constraint clustered (vs. non-clustered)? I would leave it non-clustered but the execution plan clearly shows that the clustered index is used in much greater percentage.
>
>The ever increasing identity column is the best candidate for the clustered PK. You made a right switch, by default SQL Server makes PK column clustered. Perhaps you originally somehow made it non-clustered.

I think originally this column was not INT but NUMERIC(6,0) and I later changed it to INT. Could this have confused SQL Server and caused the PK column to be non-clustered?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform