SlideShare a Scribd company logo
Unique Identifiers - GUIDs
Presentation by Aaron Buma
Development DBA
Session Overview
• Overview
• Generation
• Comparison and Non-Comparison Operations
• Advantages and Disadvantages
GUID Overview
• GUID – Global Unique Identifier
• Unique – 2^128 possible values
• A unique 16-byte number
• Can be auto-generated on a column
– IDENTITY and TIMESTAMP (2008-)/ROWVERSION(2008+)
GUID Generation
• On the fly:
• From a String (too long of string will be trimmed):
• Auto-Generate:
GUID Generation
• NEWID:
– A random 16 byte identifier
• NEWSEQUENTIALID:
– Can only be a DEFAULT when record is created
Comparison (and non) Operations
Can Use Can’t Use
=, !=, <> +, -, *, /
<, <=, >, >=
LIKE
BETWEEN
IS NULL and IS NOT NULL
GUIDs and ORDER BY
• When using “ORDER BY” on a GUID column, the data
is sorted on the last section of the GUID
DEMOS
Advantages of GUIDs
• Identifying data from multiple sources
– An advantage over IDENTITY
• Can be generated offline
Disadvantages of GUIDs
• Data Size: 4x larger than INT
– Slower and Larger Indexes
– Page Splits on Indexes (fragmentation)
• Slowest JOIN performance
• Slowest INSERT/UPDATE performance
• Slowest SORT performance
Disadvantages of GUIDs
• Adding/Removing GUIDs will cause fragmentation on
indexes if GUIDs are used for:
– Primary Keys
• GUIDs have least performance on JOINS, so not only is
JOINING on a GUID slow, but joining to a fragmented
index is even slower
– Clustering
Advantage vs Disadvantages
<
Review
• Overview
• Generation
• Comparison and Non-Comparison Operations
• Advantages and Disadvantages
Presentation Recording, Slides and Scripts
– Available at:
http://www.aaronbuma.com/2015/10/guids/

More Related Content

PPTX
XQuery Extensions
PPT
Spatial data types
PPT
SQL Server - Constraints
PDF
SQL Triggers
PPT
SQL Views
PPTX
My Query is slow, now what?
PDF
A basic approach to Understanding Win32 Binaries
XQuery Extensions
Spatial data types
SQL Server - Constraints
SQL Triggers
SQL Views
My Query is slow, now what?
A basic approach to Understanding Win32 Binaries

Similar to SQL Server GUIDS (Globally Unique Identifiers) (15)

PDF
Sql Performance Tuning For Developers
PDF
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
PPTX
SQL Server Worst Practices - EN
PDF
Billion Goods in Few Categories: How Histograms Save a Life?
PDF
Billion Goods in Few Categories: how Histograms Save a Life?
PPT
Frist slider share
ODP
BlaBlaCar Elastic Search Feedback
PPTX
Old code doesn't stink
PDF
Postgres for MySQL (and other database) people
PPTX
Linux I2C
PPTX
MySQL performance monitoring using Statsd and Graphite (PLUK2013)
PPTX
RedisConf18 - RedisUnique
PPT
10 instruction sets characteristics
PPTX
Infrastructure as Code (IaC): Introduction to scripted infrastructure
Sql Performance Tuning For Developers
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
SQL Server Worst Practices - EN
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?
Frist slider share
BlaBlaCar Elastic Search Feedback
Old code doesn't stink
Postgres for MySQL (and other database) people
Linux I2C
MySQL performance monitoring using Statsd and Graphite (PLUK2013)
RedisConf18 - RedisUnique
10 instruction sets characteristics
Infrastructure as Code (IaC): Introduction to scripted infrastructure
Ad

Recently uploaded (20)

PDF
AI in Product Development-omnex systems
PPTX
L1 - Introduction to python Backend.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
history of c programming in notes for students .pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
AI in Product Development-omnex systems
L1 - Introduction to python Backend.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
history of c programming in notes for students .pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How to Choose the Right IT Partner for Your Business in Malaysia
Softaken Excel to vCard Converter Software.pdf
Design an Analysis of Algorithms I-SECS-1021-03
medical staffing services at VALiNTRY
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Operating system designcfffgfgggggggvggggggggg
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 2 - PM Management and IT Context
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Reimagine Home Health with the Power of Agentic AI​
VVF-Customer-Presentation2025-Ver1.9.pptx
Ad

SQL Server GUIDS (Globally Unique Identifiers)

  • 1. Unique Identifiers - GUIDs Presentation by Aaron Buma Development DBA
  • 2. Session Overview • Overview • Generation • Comparison and Non-Comparison Operations • Advantages and Disadvantages
  • 3. GUID Overview • GUID – Global Unique Identifier • Unique – 2^128 possible values • A unique 16-byte number • Can be auto-generated on a column – IDENTITY and TIMESTAMP (2008-)/ROWVERSION(2008+)
  • 4. GUID Generation • On the fly: • From a String (too long of string will be trimmed): • Auto-Generate:
  • 5. GUID Generation • NEWID: – A random 16 byte identifier • NEWSEQUENTIALID: – Can only be a DEFAULT when record is created
  • 6. Comparison (and non) Operations Can Use Can’t Use =, !=, <> +, -, *, / <, <=, >, >= LIKE BETWEEN IS NULL and IS NOT NULL
  • 7. GUIDs and ORDER BY • When using “ORDER BY” on a GUID column, the data is sorted on the last section of the GUID
  • 9. Advantages of GUIDs • Identifying data from multiple sources – An advantage over IDENTITY • Can be generated offline
  • 10. Disadvantages of GUIDs • Data Size: 4x larger than INT – Slower and Larger Indexes – Page Splits on Indexes (fragmentation) • Slowest JOIN performance • Slowest INSERT/UPDATE performance • Slowest SORT performance
  • 11. Disadvantages of GUIDs • Adding/Removing GUIDs will cause fragmentation on indexes if GUIDs are used for: – Primary Keys • GUIDs have least performance on JOINS, so not only is JOINING on a GUID slow, but joining to a fragmented index is even slower – Clustering
  • 13. Review • Overview • Generation • Comparison and Non-Comparison Operations • Advantages and Disadvantages Presentation Recording, Slides and Scripts – Available at: http://www.aaronbuma.com/2015/10/guids/