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

  • Home
  • SEARCH
  • 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 7729531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:59:29+00:00 2026-06-01T05:59:29+00:00

We have a table with a CreateDateTime PK. The program that does the inserts

  • 0

We have a table with a CreateDateTime PK. The program that does the inserts is multithreaded. Obviously, this is not thread safe. There is a 3 column composite key that can be made from existing data in the table. This is a logging table and the traffic is expected to be high. Performance is the main concern.

One of our developers believes that because the way SQL internally stores datetime’s (Epoch?), DateTime is an optimal PK for performance reasons.

I suggested we create a composite key out of 3 columns. Will this key change negatively impact performance?

It has also been suggested that we use GUID PK’s. Once again, performance is in question.

Is it best to switch over to a composite key? If yes, how can we address/explain these performance concerns?

  • 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-06-01T05:59:31+00:00Added an answer on June 1, 2026 at 5:59 am

    GUIDs may seem to be a natural choice for your primary key – and if you really must, you could probably argue to use it for the PRIMARY KEY of the table. What I’d strongly recommend not to do is use the GUID column as the clustering key, which SQL Server does by default, unless you specifically tell it not to.

    You really need to keep two issues apart:

    1) the primary key is a logical construct – one of the candidate keys that uniquely and reliably identifies every row in your table. This can be anything, really – an INT, a GUID, a string – pick what makes most sense for your scenario.

    2) the clustering key (the column or columns that define the “clustered index” on the table) – this is a physical storage-related thing, and here, a small, stable, ever-increasing data type is your best pick – INT or BIGINT as your default option.

    By default, the primary key on a SQL Server table is also used as the clustering key – but that doesn’t need to be that way! I’ve personally seen massive performance gains when breaking up the previous GUID-based Primary / Clustered Key into two separate key – the primary (logical) key on the GUID, and the clustering (ordering) key on a separate INT IDENTITY(1,1) column.

    As Kimberly Tripp – the Queen of Indexing – and others have stated a great many times – a GUID as the clustering key isn’t optimal, since due to its randomness, it will lead to massive page and index fragmentation and to generally bad performance.

    Yes, I know – there’s newsequentialid() in SQL Server 2005 and up – but even that is not truly and fully sequential and thus also suffers from the same problems as the GUID – just a bit less prominently so.

    Then there’s another issue to consider: the clustering key on a table will be added to each and every entry on each and every non-clustered index on your table as well – thus you really want to make sure it’s as small as possible. Typically, an INT with 2+ billion rows should be sufficient for the vast majority of tables – and compared to a GUID as the clustering key, you can save yourself hundreds of megabytes of storage on disk and in server memory.

    Quick calculation – using INT vs. GUID as Primary and Clustering Key:

    • Base Table with 1’000’000 rows (3.8 MB vs. 15.26 MB)
    • 6 nonclustered indexes (22.89 MB vs. 91.55 MB)

    TOTAL: 25 MB vs. 106 MB – and that’s just on a single table!

    Some more food for thought – excellent stuff by Kimberly Tripp – read it, read it again, digest it! It’s the SQL Server indexing gospel, really.

    • GUIDs as PRIMARY KEY and/or clustered key
    • The clustered index debate continues
    • Ever-increasing clustering key – the Clustered Index Debate……….again!
    • Disk space is cheap – that’s not the point!

    As for composite keys : the main drawback in my opinion is the fact that all tables that want to reference this composite PK now have to have a composite FK with all the columns defined in the composite PK. This gets really unwieldy when you have a lot of queries that need to join child tables to a table with this composite keys.

    DATEITME alone doesn’t seem like a good idea for a primary key – in SQL Server, the DATETIME has an accuracy of 3.33ms, so there’s a good chance in a busy system that you’ll have non-unique values – not a good idea for a PK !

    If performance is your utmost priority, then I would definitely recommend a single INT IDENTITY column (even if it’s a surrogate column) to be used for your unique, clustered primary key index.

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

Sidebar

Related Questions

I have table with some fields that the value will be 1 0. This
I have table in an MS Access database that looks like this: ID Symbol
I have table named A with column B defined int not null Primary Key
I have table named lantable in sqlite database where there is a column named
I have table with millions of records (rows). And in this table there is
I have table that has a column of type DateTime, I would like to
I hope this is not a duplicate of a question, but I have three
I have table with Persian data and utf8_general_ci collection and with php program i
I have table defined with FlexiGrid. Call to all variables is ok. One column
I have table with this structure ID | Parameter1 | Parameter 2 | Multiplication

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.