SlideShare uma empresa Scribd logo
1 de 15
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:

Mais conteúdo relacionado

Destaque

โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียนsiripa
 
โปรแกรมการเรียน
โปรแกรมการเรียนโปรแกรมการเรียน
โปรแกรมการเรียน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 Planboylovell
 
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 JlsynaveTechnofutur TIC
 

Destaque (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
 

Semelhante a GUID vs INT: Which is Best for Your Project

Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11Divide and Rule partitioning in pg11
Divide and Rule partitioning in pg11Rajni 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 2014Dave Stokes
 
Analysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsAnalysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsIRJET 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 ImagesEditor 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 Performanceguest9912e5
 
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 stackInfluxData
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuEstelaJeffery653
 
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
 
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 GDC14AMD 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 CloudIRJET 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
 
Barcode printing presentation lgi
Barcode printing presentation lgiBarcode printing presentation lgi
Barcode printing presentation lgiVan Chiang
 

Semelhante a GUID vs INT: Which is Best for Your Project (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
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

GUID vs INT: Which is Best for Your Project

  • 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: