SlideShare a Scribd company logo
1 of 16
SQL Server 2014
Hekaton – Multiversion Concurrency Control
Francesco Milano
fmilano@solidq.com
PILLS SPONSORS
Francesco Milano
SQL Server
5+ anni di esperienza
SQL Server 2005, 2008, 2008R2, 2012
Progettazione, sviluppo, integrazione, ottimizzazione
Data Platform Specialist @ SolidQ
.NET
10+ anni di esperienza
Focus primario su soluzioni Web e Back-End
Membro UGISS
Speaker, blogger
What’s before 
Hekaton – In Memory Tables (Davide Mauri)
http://vimeo.com/83218500
Hekaton – Multiversion Concurrency
Control
SQL Server 2014 introduce importanti novità per
ottimizzare accesso e modifica di dati completamente in
memory
Nuova struttura di indici e tabelle
Nuovo meccanismo di concorrenza lock-free e latch-free

Sono gli indici a legare tra loro le righe
Almeno un indice deve esistere per ogni tabella 
Hekaton – Multiversion Concurrency
Control
Le tabelle in memory supportano due tipologie di indici
Hash indexes
Range indexes (CTP2)
Gli indici sono definiti e creati contestualmente alla tabella
Non vengono mai persistiti su disco

Massimo 8 indici per tabella
Hekaton – Multiversion Concurrency
Control

From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
Hekaton – Multiversion Concurrency
Control
Hash indexes
Array di puntatori
Ogni elemento è chiamato hash
bucket
Per ogni riga viene calcolato un hash
sulle sue colonne chiave
Chiavi che producono le stesso hash
sono accedute dallo stesso hash
bucket e sono legate tra loro in una
catena

Ideali per chiavi con cardinalità
ragionevolmente nota a priori e per
richerche puntuali

From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
Hekaton – Multiversion Concurrency
Control

From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
Hekaton – Multiversion Concurrency
Control
Range indexes (BW-Tree)
Ogni pagina ha un proprio PID. Il
collegamento con l’indirizzo di memoria
della pagina avviene tramite una tabella di
mapping
Le pagine hanno dimensione variabile
(massimo 8k) e non vengono mai
modificate; INSERT o DELETE di una
chiave generano Delta pages che integrano
la variazione
Le pagine foglia contengono un puntatore
alle righe in memoria; come per gli indici
hash, righe con chiavi uguali sono legate in
una catena

From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
Ideali per chiavi di cui non è ipotizzabile a
priori il bucket count o che verranno cercate
per range di valori
Hekaton – Multiversion Concurrency
Control
Le operazioni sui dati di tabelle in memory usano sempre un
Optimistic Multiversion Concurrency Control (MVCC)
Le righe non vengono modificate direttamente, ma vengono create
nuove versioni della stessa riga con finestre temporali di validità più
recenti
Lavorando in concorrenza ottimistica, se due transazioni attive
cercano di modificare la stessa riga, la seconda transazione viene
abortita
E’importante gestire il retry dell’operazione 
Hekaton – Multiversion Concurrency
Control
Un contatore monotonico crescente, identificato come
timestamp, viene incrementato ad ogni commit di una transazione
Ogni versione di un record possiede due timestamps:
Begin-Ts – commit time della transazione che l’ha generata
End-Ts – commit time della transazione che l’ha “eliminata”
Il periodo di validità (valid time) della versione di un record denota il
range di timestamps in cui tale versione risulta visibile alle altre
transazioni
Hekaton – Multiversion Concurrency
Control
TX1 (ID = 89)
1) Begin timestamp =
240
89

2) DELETE Greg, Lisbon
3) UPDATE
Jane, Helsinki
To -> Jane, Perth

89

89

4) Commit TX1
End timestamp = 250

From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
Hekaton – Multiversion Concurrency
Control
Sistema concettualmente simile allo SNAPSHOT Isolation, ma:
Nessun carico sul TempDB
Nessun blocco in UPDATE o DELETE
Pienamente transazionale (ACID properties)
Scritture nel Transaction Log drasticamente ridotte
Footprint minimo
Dati sporchi non vengono mai persistiti
What’s next

Hekaton - Natively Compiled Stored Procedures
Grazie!
Trovi altri video su:
www.ugiss.org/sql-server-2014pills

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Hekaton: Multiversion Concurrency Control ed indici

  • 1. SQL Server 2014 Hekaton – Multiversion Concurrency Control Francesco Milano fmilano@solidq.com
  • 3. Francesco Milano SQL Server 5+ anni di esperienza SQL Server 2005, 2008, 2008R2, 2012 Progettazione, sviluppo, integrazione, ottimizzazione Data Platform Specialist @ SolidQ .NET 10+ anni di esperienza Focus primario su soluzioni Web e Back-End Membro UGISS Speaker, blogger
  • 4. What’s before  Hekaton – In Memory Tables (Davide Mauri) http://vimeo.com/83218500
  • 5. Hekaton – Multiversion Concurrency Control SQL Server 2014 introduce importanti novità per ottimizzare accesso e modifica di dati completamente in memory Nuova struttura di indici e tabelle Nuovo meccanismo di concorrenza lock-free e latch-free Sono gli indici a legare tra loro le righe Almeno un indice deve esistere per ogni tabella 
  • 6. Hekaton – Multiversion Concurrency Control Le tabelle in memory supportano due tipologie di indici Hash indexes Range indexes (CTP2) Gli indici sono definiti e creati contestualmente alla tabella Non vengono mai persistiti su disco Massimo 8 indici per tabella
  • 7. Hekaton – Multiversion Concurrency Control From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
  • 8. Hekaton – Multiversion Concurrency Control Hash indexes Array di puntatori Ogni elemento è chiamato hash bucket Per ogni riga viene calcolato un hash sulle sue colonne chiave Chiavi che producono le stesso hash sono accedute dallo stesso hash bucket e sono legate tra loro in una catena Ideali per chiavi con cardinalità ragionevolmente nota a priori e per richerche puntuali From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
  • 9. Hekaton – Multiversion Concurrency Control From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
  • 10. Hekaton – Multiversion Concurrency Control Range indexes (BW-Tree) Ogni pagina ha un proprio PID. Il collegamento con l’indirizzo di memoria della pagina avviene tramite una tabella di mapping Le pagine hanno dimensione variabile (massimo 8k) e non vengono mai modificate; INSERT o DELETE di una chiave generano Delta pages che integrano la variazione Le pagine foglia contengono un puntatore alle righe in memoria; come per gli indici hash, righe con chiavi uguali sono legate in una catena From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf Ideali per chiavi di cui non è ipotizzabile a priori il bucket count o che verranno cercate per range di valori
  • 11. Hekaton – Multiversion Concurrency Control Le operazioni sui dati di tabelle in memory usano sempre un Optimistic Multiversion Concurrency Control (MVCC) Le righe non vengono modificate direttamente, ma vengono create nuove versioni della stessa riga con finestre temporali di validità più recenti Lavorando in concorrenza ottimistica, se due transazioni attive cercano di modificare la stessa riga, la seconda transazione viene abortita E’importante gestire il retry dell’operazione 
  • 12. Hekaton – Multiversion Concurrency Control Un contatore monotonico crescente, identificato come timestamp, viene incrementato ad ogni commit di una transazione Ogni versione di un record possiede due timestamps: Begin-Ts – commit time della transazione che l’ha generata End-Ts – commit time della transazione che l’ha “eliminata” Il periodo di validità (valid time) della versione di un record denota il range di timestamps in cui tale versione risulta visibile alle altre transazioni
  • 13. Hekaton – Multiversion Concurrency Control TX1 (ID = 89) 1) Begin timestamp = 240 89 2) DELETE Greg, Lisbon 3) UPDATE Jane, Helsinki To -> Jane, Perth 89 89 4) Commit TX1 End timestamp = 250 From: In-Memory OLTP WhitePaper - http://bit.ly/1fndSuf
  • 14. Hekaton – Multiversion Concurrency Control Sistema concettualmente simile allo SNAPSHOT Isolation, ma: Nessun carico sul TempDB Nessun blocco in UPDATE o DELETE Pienamente transazionale (ACID properties) Scritture nel Transaction Log drasticamente ridotte Footprint minimo Dati sporchi non vengono mai persistiti
  • 15. What’s next Hekaton - Natively Compiled Stored Procedures
  • 16. Grazie! Trovi altri video su: www.ugiss.org/sql-server-2014pills