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 7634845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:17:12+00:00 2026-05-31T07:17:12+00:00

I have a situation where I have a database with several tables and large

  • 0

I have a situation where I have a database with several tables and large number of records in them , let’s say

Database 1
 - tbl1
 - tbl2
 - tbl3
 - tbln

The tables have PK-FK relationships. The datatype of the PK’s are of type ‘uniqueIdentifier’. Recently I read that having uniqueIdentifier as the datatype can hamper the performance, and it is always better to have integer type for a PK, as it can result it faster indexes.

So we have decided to alter the tables to have the PK datatype as integer Identity. Rest all the structure would remain the same. Also this database have some data in it which should be intact.

Can somebody help me out with the best approach to solve this problem
– After the update, the data and the PK-FK relationships should remain intact.

This is our approach of doing it –

  • Create a new table [DB2] with PK datatype as integer Identity
  • Add all the PK-FK relationships
  • Write a program to migrate the data from DB1 to DB2

We know that this is not a small task because it involves a lot of tables with PK-FK relationships

  • Is there a better way of doing this?
  • Can we make the alteration/updation on the original database itself without having to create a 2nd Database and then migrate data into it?

Any help appreciated. Thanks.

  • 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-31T07:17:13+00:00Added an answer on May 31, 2026 at 7:17 am

    A GUID can hamper performance but won’t necessarily. I use them all the time, and I use integer-based primary keys as well, depending on the situation.

    Unless you can point to a specific performance issue, my advice is to leave well enough alone.

    The biggest issue with using uniqueidentifier is how you generate new ID values, especially if the primary key is in the clustered index. If you use NEWID(), it’s fairly random, so it may insert anywhere within the table space, causing unnecessary page splits. Using NEWSEQUENTIALID() is better since it creates sequential uniqueidentifiers, but it has a new random seed each time the database starts, so it doesn’t always append to the end of the table either.

    The best solution IMHO is to use a COMB-style GUID that has a portion that is based on the timestamp (which is of course monotonically increasing) and a portion that is random. (As a tiny side-benefit, you can decode the timestamp portion if you ever need to know when the INSERT occurred, assuming the information isn’t stored elsewhere as well.)

    Here’s an example COMB function:

    CREATE FUNCTION [dbo].NewCOMB(@GUID uniqueidentifier)
    RETURNS uniqueidentifier AS BEGIN
       RETURN CAST(
           CAST(NEWID() AS binary(10)) 
           + CAST(GETDATE() AS binary(6)) 
         AS uniqueidentifier)
    END;
    

    Here’s a great article on the subject, a little dated but still good:

    http://www.informit.com/articles/article.aspx?p=25862&seqNum=7

    If you find you must change horses, do it this way:

    • Add new ID columns to each table under a different name
    • Populate them
    • Index them as needed
    • Remove the table constraints on the old columns
    • Add new constraints for the new columns
    • Remove the old columns
    • Rename the new columns to the old names (if needed)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple situation. A large organisation is using several different versions of
I have a situation which involves several threads simultaneously populating a database with data
I have situation in which I read a record from a database. And if
We have a bit of a messy database situation. Our main back-office system is
I have a situation where our developers extended a Third party database (MS SQL)
We have a situation where we need to display data from a database in
I used to have a situation where I hit the database a every time
I have an unusual situation to model in a MS SQL Server database: the
Here's the situation: we have an Oracle database we need to connect to to
We've encountered the following situation in our database. We have table 'A' and table

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.