SlideShare a Scribd company logo
GUID vs INT
DEBATE
Francisco J. Carabez
V1.0 Feb 25 2014
INT
ADVANTAGE
Has better performance when used in joins, indexes and conditions.
Numeric values are easier to understand for application’s users if
they are displayed.
Widely used for incrementing key values serially.
Less space for storing.
GUID
ADVANTAGE
Unique across the [universe] servers.
Client side generated. With GUID, the client application can
generate a new value and can send it to the server. It does not need
to wait till the SAVE function returns to know what is the ID.
Consolidation and syncronization. You have Customer Table in 5
different Databases and you want to make a Data warehouse – no
problem – the records can keep their keys.
GUID
ANATOMY
A GUID is most commonly showed as text as a sequence of
hexadecimal digits separated into five groups, such as:
{3F2504E0-4F89-41D3-9A0C-0305E82C3301}
This text notation contains the following fields, separated by hyphens:
Hex digits Description
8 Data1
4 Data2
4 Data3
4 Initial two bytes from Data4
12 Remaining six bytes from Data4
INT, BIGINT & GUID
SPACE
INT
INT (4 bytes or 32bits)
++Native and faster to manage in older Pcs.
++Less space for Indexing.
BIGINT
GUID
BIGINT (8 bytes or 64bits)
++Native and faster to manage in new Pcs.
+Moderate space for Indexing.
GUID (16 bytes or 128bits)
+Practical without performance hits on new Pcs.
-Fragmentation hits on Indexing.
-More space for storing.
Cast BIGINT as GUID8
THE BETTER OF BOTH WORLD
Practical unique for most database systems, meaning easier
integration with replication
Semi-random client side or server side generated.
Semi-Sequential based on date-time stamp.
Not Fragmentation hits on indexes.
GUID8
ANATOMY
LOW INT (lower 4 bytes)
Hold seconds elapsed since Jan 1, 2000.
HI
HI INT (upper 4 bytes)
Random number.
LOW
GUID8
Date-time stamp RANGE?
One Year has 31536000 Seconds (365*24*60*60)
Lower INT can hold 4294967295
4294967295 / 31536000 = 136 years
The GUID8 time stamp approach is safe from YEAR
2000-2136
GUID8
Probability of one DUPLICATE?
Lower INT hold the Date-Time stamp in seconds.
For every second, the upper INT can hold a
RANDOM Number in range from 0 to 4,294,967,295
So having a duplicate is possible but far probable.
FACTS
ON DATABASE MANAGEMENT
GUID is hard to read or typing... Yes but come on! if you're querying that much at
once, you're probably doing it wrong anyhow.
No all tables needs a GUID.
Cost of storage are cheaper and computers are fasters.
GUID Allows asynchronous architectures more easily.
GUID guiltless used by: IPv6, Electronics Devices, Item tagging, OS…
GUID8
GENERATION CODE SQL
SELECT
CAST(
(
CAST(
( EXTRACT(DAY FROM now()-'2001-01-01')*(24*60*60) ) +
( EXTRACT(HOUR FROM now()) * (60*60) ) +
( EXTRACT(MINUTE FROM now()) * (60) ) +
EXTRACT(SECOND FROM now())
AS BIGINT ) << 32
)
+
CAST ( CAST( ROUND(RANDOM()*999999999) AS INT) AS BIGINT )
AS BIGINT )
GUID8
GENERATION CODE postgreSQL
DECLARE
IntLower int;
IntUpper int;
DateNow timestamp;
IntDias int;
IntHoras int;
IntMinutos int;
IntSegundos int;
BigIntReturn bigint;
BEGIN
DateNow = NOW();
IntDias = EXTRACT(DAY FROM DateNow-'2000-01-01'::date)::int;
IntHoras = EXTRACT(HOUR FROM DateNow)::int;
IntMinutos = EXTRACT(MINUTE FROM DateNow)::int;
IntSegundos = EXTRACT(SECOND FROM DateNow)::int;
IntLower := ( IntDias*(24*60*60) ) + IntHoras*(60*60) + IntMinutos*60 + IntSegundos;
IntUpper := ROUND(RANDOM()*999999999)::int;
BigIntReturn := (IntLower::bigint << 32)+IntUpper;
RETURN (BigIntReturn);
END;
OUR PROJECT
REPLICATION & SINCRONATION
QUESTIONS?
THANK YOU!
Download this presentation:
http://www.carabez.com/downloads/sql_guid_vs_int.zip
More Info:
http://es.wikipedia.org/wiki/Globally_unique_identifier
http://betterexplained.com/articles/the-quick-guide-to-guids/
http://krow.livejournal.com/497839.html
http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int-
your-opinion/
LINKS
For review:

More Related Content

Viewers also liked

Do you remember ppt
Do you remember pptDo you remember ppt
โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียน
siripa
 
Codigolimpio
CodigolimpioCodigolimpio
Codigolimpio
Francisco Carabez
 
โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียน
siripa
 
The Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
The Lunch Box Diet: Rainbow 28 Day Weight Loss PlanThe Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
The Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
boylovell
 
Do's & Donts in Preparing PowerPoint Presentation
Do's & Donts in Preparing PowerPoint PresentationDo's & Donts in Preparing PowerPoint Presentation
Do's & Donts in Preparing PowerPoint Presentationloisvil
 
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...Raphaël Fétique
 
Ecommerce Business Models Jlsynave
Ecommerce Business Models JlsynaveEcommerce Business Models Jlsynave
Ecommerce Business Models Jlsynave
Technofutur TIC
 

Viewers also liked (8)

Do you remember ppt
Do you remember pptDo you remember ppt
Do you remember ppt
 
โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียน
 
Codigolimpio
CodigolimpioCodigolimpio
Codigolimpio
 
โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียน
 
The Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
The Lunch Box Diet: Rainbow 28 Day Weight Loss PlanThe Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
The Lunch Box Diet: Rainbow 28 Day Weight Loss Plan
 
Do's & Donts in Preparing PowerPoint Presentation
Do's & Donts in Preparing PowerPoint PresentationDo's & Donts in Preparing PowerPoint Presentation
Do's & Donts in Preparing PowerPoint Presentation
 
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...
Café du e-Commerce 18mars2009 - Le site web peut-il rivaliser avec le conseil...
 
Ecommerce Business Models Jlsynave
Ecommerce Business Models JlsynaveEcommerce Business Models Jlsynave
Ecommerce Business Models Jlsynave
 

Similar to Sql guid vs int debate

Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11
Rajni Baliyan
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
Dave Stokes
 
Analysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsAnalysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithms
IRJET Journal
 
Implementation of 2D Optimal Barcode (QR Code) for Images
Implementation of 2D Optimal Barcode (QR Code) for ImagesImplementation of 2D Optimal Barcode (QR Code) for Images
Implementation of 2D Optimal Barcode (QR Code) for Images
Editor IJCATR
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
guest9912e5
 
Combating data leakage trojans in commercial and asic applications with time ...
Combating data leakage trojans in commercial and asic applications with time ...Combating data leakage trojans in commercial and asic applications with time ...
Combating data leakage trojans in commercial and asic applications with time ...
Nxfee Innovation
 
Virtual training optimizing the tick stack
Virtual training  optimizing the tick stackVirtual training  optimizing the tick stack
Virtual training optimizing the tick stack
InfluxData
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structu
EstelaJeffery653
 
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
Zilliz
 
Introducing an Encryption Algorithm based on IDEA
Introducing an Encryption Algorithm based on IDEAIntroducing an Encryption Algorithm based on IDEA
Introducing an Encryption Algorithm based on IDEA
International Journal of Science and Research (IJSR)
 
Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14
AMD Developer Central
 
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On CloudSecure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
IRJET Journal
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
Altinity Ltd
 
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
IJNSA Journal
 
IBMHadoopofferingTechline-Systems2015
IBMHadoopofferingTechline-Systems2015IBMHadoopofferingTechline-Systems2015
IBMHadoopofferingTechline-Systems2015Daniela Zuppini
 
IRJET- Review on Privacy Preserving on Multi Keyword Search over Encrypte...
IRJET-  	  Review on Privacy Preserving on Multi Keyword Search over Encrypte...IRJET-  	  Review on Privacy Preserving on Multi Keyword Search over Encrypte...
IRJET- Review on Privacy Preserving on Multi Keyword Search over Encrypte...
IRJET Journal
 
InfiniBox z pohledu zákazníka
InfiniBox z pohledu zákazníkaInfiniBox z pohledu zákazníka
InfiniBox z pohledu zákazníka
MarketingArrowECS_CZ
 
Barcode printing presentation lgi
Barcode printing presentation lgiBarcode printing presentation lgi
Barcode printing presentation lgiVan Chiang
 

Similar to Sql guid vs int debate (20)

Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
 
Analysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsAnalysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithms
 
Implementation of 2D Optimal Barcode (QR Code) for Images
Implementation of 2D Optimal Barcode (QR Code) for ImagesImplementation of 2D Optimal Barcode (QR Code) for Images
Implementation of 2D Optimal Barcode (QR Code) for Images
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
Combating data leakage trojans in commercial and asic applications with time ...
Combating data leakage trojans in commercial and asic applications with time ...Combating data leakage trojans in commercial and asic applications with time ...
Combating data leakage trojans in commercial and asic applications with time ...
 
Virtual training optimizing the tick stack
Virtual training  optimizing the tick stackVirtual training  optimizing the tick stack
Virtual training optimizing the tick stack
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structu
 
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
VectorDB Schema Design 101 - Considerations for Building a Scalable and Perfo...
 
Introducing an Encryption Algorithm based on IDEA
Introducing an Encryption Algorithm based on IDEAIntroducing an Encryption Algorithm based on IDEA
Introducing an Encryption Algorithm based on IDEA
 
NWSLTR_Volume12_Issue1
NWSLTR_Volume12_Issue1NWSLTR_Volume12_Issue1
NWSLTR_Volume12_Issue1
 
Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14Direct3D and the Future of Graphics APIs - AMD at GDC14
Direct3D and the Future of Graphics APIs - AMD at GDC14
 
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On CloudSecure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
Secure Text Transfer Using Diffie-Hellman Key Exchange Based On Cloud
 
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
 
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
PERFORMANCE EVALUATION OF PARALLEL INTERNATIONAL DATA ENCRYPTION ALGORITHM ON...
 
IBMHadoopofferingTechline-Systems2015
IBMHadoopofferingTechline-Systems2015IBMHadoopofferingTechline-Systems2015
IBMHadoopofferingTechline-Systems2015
 
IRJET- Review on Privacy Preserving on Multi Keyword Search over Encrypte...
IRJET-  	  Review on Privacy Preserving on Multi Keyword Search over Encrypte...IRJET-  	  Review on Privacy Preserving on Multi Keyword Search over Encrypte...
IRJET- Review on Privacy Preserving on Multi Keyword Search over Encrypte...
 
InfiniBox z pohledu zákazníka
InfiniBox z pohledu zákazníkaInfiniBox z pohledu zákazníka
InfiniBox z pohledu zákazníka
 
Barcode printing presentation lgi
Barcode printing presentation lgiBarcode printing presentation lgi
Barcode printing presentation lgi
 
Pulpit operatorski Mitsubishi GOT2000 HMI
Pulpit operatorski Mitsubishi GOT2000 HMIPulpit operatorski Mitsubishi GOT2000 HMI
Pulpit operatorski Mitsubishi GOT2000 HMI
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

Sql guid vs int debate

  • 1. GUID vs INT DEBATE Francisco J. Carabez V1.0 Feb 25 2014
  • 2. INT ADVANTAGE Has better performance when used in joins, indexes and conditions. Numeric values are easier to understand for application’s users if they are displayed. Widely used for incrementing key values serially. Less space for storing.
  • 3. GUID ADVANTAGE Unique across the [universe] servers. Client side generated. With GUID, the client application can generate a new value and can send it to the server. It does not need to wait till the SAVE function returns to know what is the ID. Consolidation and syncronization. You have Customer Table in 5 different Databases and you want to make a Data warehouse – no problem – the records can keep their keys.
  • 4. GUID ANATOMY A GUID is most commonly showed as text as a sequence of hexadecimal digits separated into five groups, such as: {3F2504E0-4F89-41D3-9A0C-0305E82C3301} This text notation contains the following fields, separated by hyphens: Hex digits Description 8 Data1 4 Data2 4 Data3 4 Initial two bytes from Data4 12 Remaining six bytes from Data4
  • 5. INT, BIGINT & GUID SPACE INT INT (4 bytes or 32bits) ++Native and faster to manage in older Pcs. ++Less space for Indexing. BIGINT GUID BIGINT (8 bytes or 64bits) ++Native and faster to manage in new Pcs. +Moderate space for Indexing. GUID (16 bytes or 128bits) +Practical without performance hits on new Pcs. -Fragmentation hits on Indexing. -More space for storing.
  • 6. Cast BIGINT as GUID8 THE BETTER OF BOTH WORLD Practical unique for most database systems, meaning easier integration with replication Semi-random client side or server side generated. Semi-Sequential based on date-time stamp. Not Fragmentation hits on indexes.
  • 7. GUID8 ANATOMY LOW INT (lower 4 bytes) Hold seconds elapsed since Jan 1, 2000. HI HI INT (upper 4 bytes) Random number. LOW
  • 8. GUID8 Date-time stamp RANGE? One Year has 31536000 Seconds (365*24*60*60) Lower INT can hold 4294967295 4294967295 / 31536000 = 136 years The GUID8 time stamp approach is safe from YEAR 2000-2136
  • 9. GUID8 Probability of one DUPLICATE? Lower INT hold the Date-Time stamp in seconds. For every second, the upper INT can hold a RANDOM Number in range from 0 to 4,294,967,295 So having a duplicate is possible but far probable.
  • 10. FACTS ON DATABASE MANAGEMENT GUID is hard to read or typing... Yes but come on! if you're querying that much at once, you're probably doing it wrong anyhow. No all tables needs a GUID. Cost of storage are cheaper and computers are fasters. GUID Allows asynchronous architectures more easily. GUID guiltless used by: IPv6, Electronics Devices, Item tagging, OS…
  • 11. GUID8 GENERATION CODE SQL SELECT CAST( ( CAST( ( EXTRACT(DAY FROM now()-'2001-01-01')*(24*60*60) ) + ( EXTRACT(HOUR FROM now()) * (60*60) ) + ( EXTRACT(MINUTE FROM now()) * (60) ) + EXTRACT(SECOND FROM now()) AS BIGINT ) << 32 ) + CAST ( CAST( ROUND(RANDOM()*999999999) AS INT) AS BIGINT ) AS BIGINT )
  • 12. GUID8 GENERATION CODE postgreSQL DECLARE IntLower int; IntUpper int; DateNow timestamp; IntDias int; IntHoras int; IntMinutos int; IntSegundos int; BigIntReturn bigint; BEGIN DateNow = NOW(); IntDias = EXTRACT(DAY FROM DateNow-'2000-01-01'::date)::int; IntHoras = EXTRACT(HOUR FROM DateNow)::int; IntMinutos = EXTRACT(MINUTE FROM DateNow)::int; IntSegundos = EXTRACT(SECOND FROM DateNow)::int; IntLower := ( IntDias*(24*60*60) ) + IntHoras*(60*60) + IntMinutos*60 + IntSegundos; IntUpper := ROUND(RANDOM()*999999999)::int; BigIntReturn := (IntLower::bigint << 32)+IntUpper; RETURN (BigIntReturn); END;
  • 15. Download this presentation: http://www.carabez.com/downloads/sql_guid_vs_int.zip More Info: http://es.wikipedia.org/wiki/Globally_unique_identifier http://betterexplained.com/articles/the-quick-guide-to-guids/ http://krow.livejournal.com/497839.html http://blog.sqlauthority.com/2010/04/28/sql-server-guid-vs-int- your-opinion/ LINKS For review: