Primary Key Should Not be Clustered

Primary Key Should Not be Clustered

By default, when you define a primary key in the create table statement, it uses a clustered index. However, a clustered key is best used to support queries that return more than one row. For example, if you have a date field that is often used to return activity for a range of days, a clustered index will be much faster than a nonclustered one. To preserve your clustered index for other columns, you can add the keyword nonclustered to the primary constraint definition; that is, constraint pkaccount primary key nonclustered (acctid).


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist