Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:50:02+00:00 2026-05-16T02:50:02+00:00

Does SQL Server build an index on primary keys by default? If yes what

  • 0

Does SQL Server build an index on primary keys by default?
If yes what kind of index? If no what kind of index is appropriate for selections by primary key?

I use SQL Server 2008 R2

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:50:03+00:00Added an answer on May 16, 2026 at 2:50 am

    You can easily determine the first part of this for yourself

    create table x
    (
    id int primary key
    )
    
    select * from sys.indexes where object_id = object_id('x')
    

    Gives

    object_id   name             index_id    type type_desc                                                    is_unique data_space_id ignore_dup_key is_primary_key is_unique_constraint fill_factor is_padded is_disabled is_hypothetical allow_row_locks allow_page_locks
    1653580929  PK__x__6383C8BA    1           1    CLUSTERED                                                    1         1             0              1              0                    0           0         0           0               1               1
    

    Edit: There is one other case I should have mentioned

    create table t2 (id int not null, cx int)
    
    create clustered index ixc on dbo.t2 (cx asc)
    
    alter table dbo.t2 add constraint pk_t2 primary key (id) 
    
    select * from sys.indexes where object_id = object_id('t2')
    

    Gives

    object_id   name                           index_id    type type_desc                      is_unique data_space_id ignore_dup_key is_primary_key is_unique_constraint fill_factor is_padded is_disabled is_hypothetical allow_row_locks allow_page_locks has_filter filter_definition
    ----------- ------------------------------ ----------- ---- ------------------------------ --------- ------------- -------------- -------------- -------------------- ----------- --------- ----------- --------------- --------------- ---------------- ---------- ------------------------------
    34099162    ixc                            1           1    CLUSTERED                      0         1             0              0              0                    0           0         0           0               1               1                0          NULL
    34099162    pk_t2                          2           2    NONCLUSTERED                   1         1             0              1              0                    0           0         0           0               1               1                0          NULL
    

    With regard to the second part there is no golden rule it depends on your individual query workload, and what your PK is.

    For satisfying individual lookups by primary key a non clustered index will be fine. If you are doing queries against ranges these would be well served by a matching clustered index but a covering non clustered index could also suffice.

    You also need to consider the index width of the clustered index in particular as it impacts all your non clustered indexes and effect of inserts on page splits.

    I recommend the book SQL Server 2008 Query Performance Tuning Distilled to read more about the issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does SQL Server 2008 have a a data-type like MySQL's enum ?
Why does SQL server express 2008 give me this error? CREATE TABLE model (
Two Part Question: What kind of actions does SQL Server process in RAM? Of
As part of our Integration build we are installing sql server 2008 on a
Does SQL Server 2005 maintain built-in, queryable, row-level last-modified timestamp metadata? I'm doing some
Does SQL server expect numbers to be specified with digits from the latin alphabet,
Does SQL Server maintains any history to track table alterations like column add, delete,
How does SQL Server handle updates on views. I am worried about performance and
Why does Sql server doesn't allow more than one IDENTITY column in a table??
How does SQL Server determine whether a table column has low cardinality? The reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.