Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2016

    Exclamation Unanswered: GUID as Primary Key

    Is it good to have GUID as my primary key.
    We have a large DB with millions of records inside it, to have unique ID for these records we went for GUID.
    My DB indexes gets fragmented very easily and quickly.
    Is it because of this primary key?

    Please help me regarding this.

    Thanks and Regards,
    Ramkishore Sankarasubramanian

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Back in the old days before Microsoft/Sybase worked out IRL (Insert Row Locking) as a bottleneck, GUIDs were recommended as the Primary Key precisely because they did fragment the (presumably clustered) index key. They actually still work pretty well at both extremes (very high and very low volume) of the production load.

    To avoid the bottlenecks created by index fragmentation, you can consider the GUID as though it were an NK (Natural Key). This would allow your application to be unchanged while it allowed you to build a more compact and sequential PK (Primary Key) such as a sequence that would allow you to manage indexes (and possibly database file growth) more conveniently.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts