SlideShare a Scribd company logo
SQL Server Deep Dive
Open Technology Week: .NET Meetup
Denis Reznik
Data Architect at Intapp, Inc.
Microsoft Data Platform MVP
About Me
• Data Architect at Intapp, Inc.
• Microsoft Data Platform MVP
• PASS Regional Mentor, CEE
• Ukrainian Data Community Kyiv Co-Founder
• Co-author of “SQL Server MVP Deep Dives vol. 2”
How We See SQL Server
3 |
Some Magic
Query Result Set
SQL Server Deep Dive, Denis Reznik
SQL Server Network Interface
SQL Server Protocols
• Shared Memory
• TCP/IP
• Named Pipes
• VIA (Deprecated)
TDS Endpoints
TCP/IP
Shared Memory
Named Pipes
VIA
DAC
TCP/IP
Note: TDS – Tabular Data Stream
Query Processor
Parser Algebrizer Optimizer Executor
Query Processing
Plan Cache
Parser
• Check if plan is already in cache
• Check basic SQL syntax
• Returns ParseTree
Algebrizer
• Check that objects are exist and available in current execution context
• Define types for every node in ParseTree
• Returns QueryTree
• Logical representation of the query
Heap
1 .. 100
100 .. 1k
5K .. 6K
1K .. 5K
6K .. 7K
15K .. 21K
12K .. 15K
10K .. 11K
21K .. 22K
22K .. 41K
9K .. 10K
41K .. 51K
7K .. 8K
8K .. 9K
71K .. 1M
51K .. 71K
1M .. 2M
2M .. 3M
Clustered Index
…
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
Index Seek
…
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
SELECT * FROM Users
WHERE Id = 523
Index Scan
…
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
SELECT * FROM Users
Index Range Scan
…
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K
SELECT * FROM Users
WHERE Id BETWEEN 700
AND 1700
Non-Clustered Index
…
A .. Z
A .. C C .. K X .. Z
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
SELECT * FROM Users
WHERE Name = 'Donald Trump'
1 .. 2K 2K .. 4K 1M-2K .. 1M
Clustered Index
(Id)
Non-Clustered Index
(Name)
Heap
Extent N
Allocation Ordered Scan
…
1 .. 1M
1 .. 2K 2K+1 .. 4K 1M-2K .. 1M
Clustered Index (Id)
Extent 1
Index Allocation Map (IAM)
Extent 1
Extent 2
Extent N
Statistics
500
1000
10
1200
800
1 800 2000 2800 4500 5400
SELECT * FROM Users
WHERE Id BETWEEN 2100 AND 2500
SELECT * FROM Users
WHERE Id BETWEEN 100 AND 5000
Optimizer
Goal – get the optimal execution plan
Optimizer
Query Tree
Pre-Optimization
Search for trivial plan
Load statistics (simple)
Simplification – syntax transformation
Optimizer
Optimizer
Phase 0
Exploration – plan alternatives
Return Transaction Processing plan
Estimated cost < 0.2
Load statistics
Optimizer
Optimizer
Phase 1
Next set of query rules
Returns Quick Plan
Estimated cost < 1.0
Estimate parallel plan (estimation processed twice)
Optimizer
Optimizer
Phase 2
Full optimization
Returns Full Plan
Indexed views
Execution Plan != Query Plan
SELECT * FROM Users
WHERE Id = @id
@id = 97 Execution Plan
Query Plan Execution Context
Parameter Sniffing
Exec SomeProc @p
Optimizer
SQL Server Cache
Procedure cache@p
Plan is cached for the
first value of
Procedure cache
Executor
• Execute query using its Query Plan
• Get needed data from storage engine
DEMO
Parameter Sniffing
Storage Engine
Buffer Pool
Data Cache
Database File
Access Methods
Buffer Manager
Data Selection
?
What if I load 2GB value from the
disk and read this data using
NOLOCK?
Data Modification
Buffer Pool
Data Cache
Database File
Access Methods Buffer Manager
Transaction Log
Log Manager
Log Buffer
?
?
Background
ProcessesLock Manager
? 3 cases
Lock Types - Shared
S S
X
Lock Types - Exclusive
X
X
S
Lock Types - Update
U
U
S
SX
Lock Types – Intent locks
S
ISIS
DEMO
Deadlock
SQLOS
Query Execution Model
Thread Pool
Running
Suspended
Runnable
Scheduler Logical CPU
Sleeping (?)
Thread (Worker)
DEMO
Thread Pool Starvation
Summary
40 |
Thank You!
Open technology Week: .NET Meetup
Denis Reznik
Twitter: @denisreznik
Email: denisreznik@gmail.com
Blog: http://reznik.uneta.com.ua
Facebook: https://www.facebook.com/denis.reznik.5
LinkedIn: http://ua.linkedin.com/pub/denis-reznik/3/502/234

More Related Content

What's hot (19)

PDF
Netflix's Recommendation ML Pipeline Using Apache Spark: Spark Summit East ta...
Spark Summit
 
PPTX
Dive into spark2
Gal Marder
 
PDF
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Spark Summit
 
PPTX
Heat Updates - Liberty Edition
OpenStack Foundation
 
PPTX
Databricks clusters in autopilot mode
Prakash Chockalingam
 
PDF
Mail Search As A Sercive: Presented by Rishi Easwaran, Aol
Lucidworks
 
PPTX
Reactive Database Access With Slick 3
Igor Mielientiev
 
PPTX
JVM languages "flame wars"
Gal Marder
 
PDF
Faceting Optimizations for Solr: Presented by Toke Eskildsen, State & Univers...
Lucidworks
 
PDF
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
Lucidworks
 
PDF
Artmosphere Demo
Keira Zhou
 
PDF
A case-for-graph-db
Dhaval Dalal
 
PDF
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
AWS Chicago
 
PPTX
Sahara Updates - Liberty Edition
OpenStack Foundation
 
PDF
Sparklyr: Recap, Updates, and Use Cases with Javier Luraschi
Databricks
 
PDF
Long running aws lambda - Joel Schuweiler, Minneapolis
AWS Chicago
 
PDF
SFScon18 - Stefano Pampaloni - The SQL revenge
South Tyrol Free Software Conference
 
PDF
Real World Serverless
Petr Zapletal
 
PDF
Searchlight Updates - Liberty Edition
OpenStack Foundation
 
Netflix's Recommendation ML Pipeline Using Apache Spark: Spark Summit East ta...
Spark Summit
 
Dive into spark2
Gal Marder
 
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Spark Summit
 
Heat Updates - Liberty Edition
OpenStack Foundation
 
Databricks clusters in autopilot mode
Prakash Chockalingam
 
Mail Search As A Sercive: Presented by Rishi Easwaran, Aol
Lucidworks
 
Reactive Database Access With Slick 3
Igor Mielientiev
 
JVM languages "flame wars"
Gal Marder
 
Faceting Optimizations for Solr: Presented by Toke Eskildsen, State & Univers...
Lucidworks
 
PlayStation and Lucene - Indexing 1M documents per second: Presented by Alexa...
Lucidworks
 
Artmosphere Demo
Keira Zhou
 
A case-for-graph-db
Dhaval Dalal
 
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
AWS Chicago
 
Sahara Updates - Liberty Edition
OpenStack Foundation
 
Sparklyr: Recap, Updates, and Use Cases with Javier Luraschi
Databricks
 
Long running aws lambda - Joel Schuweiler, Minneapolis
AWS Chicago
 
SFScon18 - Stefano Pampaloni - The SQL revenge
South Tyrol Free Software Conference
 
Real World Serverless
Petr Zapletal
 
Searchlight Updates - Liberty Edition
OpenStack Foundation
 

Similar to SQL Server Deep Dive, Denis Reznik (20)

PPTX
SQL Server Deep Drive
DataArt
 
PDF
SparkSQL: A Compiler from Queries to RDDs
Databricks
 
PPTX
Se2017 query-optimizer
Mary Prokhorova
 
PPTX
.NET Fest 2019. Денис Резник. Когда SQL Server Best Practices не работают
NETFest
 
PPTX
Денис Резник "Зачем мне знать SQL и Базы Данных, ведь у меня есть ORM?"
Fwdays
 
PPTX
.NET Fest 2017. Денис Резник. Исполнение Запроса в SQL Server. Ожидание - Реа...
NETFest
 
PPTX
"Query Execution: Expectation - Reality (Level 300)" Денис Резник
Fwdays
 
PPTX
Big Data-Driven Applications with Cassandra and Spark
Artem Chebotko
 
PDF
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Spark Summit
 
PDF
Structuring Spark: DataFrames, Datasets, and Streaming by Michael Armbrust
Spark Summit
 
PDF
"What database can tell about application issues? What application can tell a...
Fwdays
 
PDF
Open Source Reliability for Data Lake with Apache Spark by Michael Armbrust
Data Con LA
 
PDF
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Databricks
 
PDF
Making Apache Spark Better with Delta Lake
Databricks
 
PPTX
Denis Reznik "Оптимизация запроса. Не знаешь что делать? Делай то, что знаешь"
Fwdays
 
PDF
The Nitty Gritty of Advanced Analytics Using Apache Spark in Python
Miklos Christine
 
PDF
Move Your XPages Applications to the Fast Lane
Teamstudio
 
PPT
LINQ-Introduction.ppt
ssusera8c91a
 
PDF
When Apache Spark Meets TiDB with Xiaoyu Ma
Databricks
 
PPTX
Paul Dix [InfluxData] | InfluxDays Opening Keynote | InfluxDays Virtual Exper...
InfluxData
 
SQL Server Deep Drive
DataArt
 
SparkSQL: A Compiler from Queries to RDDs
Databricks
 
Se2017 query-optimizer
Mary Prokhorova
 
.NET Fest 2019. Денис Резник. Когда SQL Server Best Practices не работают
NETFest
 
Денис Резник "Зачем мне знать SQL и Базы Данных, ведь у меня есть ORM?"
Fwdays
 
.NET Fest 2017. Денис Резник. Исполнение Запроса в SQL Server. Ожидание - Реа...
NETFest
 
"Query Execution: Expectation - Reality (Level 300)" Денис Резник
Fwdays
 
Big Data-Driven Applications with Cassandra and Spark
Artem Chebotko
 
Apache Carbondata: An Indexed Columnar File Format for Interactive Query with...
Spark Summit
 
Structuring Spark: DataFrames, Datasets, and Streaming by Michael Armbrust
Spark Summit
 
"What database can tell about application issues? What application can tell a...
Fwdays
 
Open Source Reliability for Data Lake with Apache Spark by Michael Armbrust
Data Con LA
 
Deep Dive Into Catalyst: Apache Spark 2.0’s Optimizer
Databricks
 
Making Apache Spark Better with Delta Lake
Databricks
 
Denis Reznik "Оптимизация запроса. Не знаешь что делать? Делай то, что знаешь"
Fwdays
 
The Nitty Gritty of Advanced Analytics Using Apache Spark in Python
Miklos Christine
 
Move Your XPages Applications to the Fast Lane
Teamstudio
 
LINQ-Introduction.ppt
ssusera8c91a
 
When Apache Spark Meets TiDB with Xiaoyu Ma
Databricks
 
Paul Dix [InfluxData] | InfluxDays Opening Keynote | InfluxDays Virtual Exper...
InfluxData
 
Ad

More from Sigma Software (20)

PPTX
Fast is Best. Using .NET MinimalAPIs
Sigma Software
 
PPTX
"Are you developing or declining? Don't become an IT-dinosaur"
Sigma Software
 
PPTX
Michael Smolin, "Decrypting customer's cultural code"
Sigma Software
 
PPTX
Max Kunytsia, “Why is continuous product discovery better than continuous del...
Sigma Software
 
PPTX
Marcelino Moreno, "Product Management Mindset"
Sigma Software
 
PDF
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
Sigma Software
 
PPTX
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
Sigma Software
 
PPTX
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
Sigma Software
 
PPTX
Stoyan Atanasov “How crucial is the BA role in an IT Project"
Sigma Software
 
PPTX
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
Sigma Software
 
PPTX
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
Sigma Software
 
PPTX
VOLVO x HACK SPRINT
Sigma Software
 
PPTX
Business digitalization trends and challenges
Sigma Software
 
PPTX
Дмитро Терещенко, "How to secure your application with Secure SDLC"
Sigma Software
 
PPTX
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
Sigma Software
 
PDF
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
Sigma Software
 
PDF
Training solutions and content creation
Sigma Software
 
PDF
False news - false truth: tips & tricks how to avoid them
Sigma Software
 
PPTX
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
Sigma Software
 
PPTX
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...
Sigma Software
 
Fast is Best. Using .NET MinimalAPIs
Sigma Software
 
"Are you developing or declining? Don't become an IT-dinosaur"
Sigma Software
 
Michael Smolin, "Decrypting customer's cultural code"
Sigma Software
 
Max Kunytsia, “Why is continuous product discovery better than continuous del...
Sigma Software
 
Marcelino Moreno, "Product Management Mindset"
Sigma Software
 
Andrii Pastushok, "Product Discovery in Outsourcing - What, When, and How"
Sigma Software
 
Elena Turkenych “BA vs PM: Who' the right person, for the right job, with the...
Sigma Software
 
Eleonora Budanova “BA+PM+DEV team: how to build the synergy”
Sigma Software
 
Stoyan Atanasov “How crucial is the BA role in an IT Project"
Sigma Software
 
Olexandra Kovalyova, "Equivalence Partitioning, Boundary Values ​​Analysis, C...
Sigma Software
 
Yana Lysa — "Decision Tables, State-Transition testing, Pairwase Testing"
Sigma Software
 
VOLVO x HACK SPRINT
Sigma Software
 
Business digitalization trends and challenges
Sigma Software
 
Дмитро Терещенко, "How to secure your application with Secure SDLC"
Sigma Software
 
Яна Лиса, “Ефективні методи написання хороших мануальних тестових сценаріїв”
Sigma Software
 
Тетяна Осетрова, “Модель зрілості розподіленної проектної команди”
Sigma Software
 
Training solutions and content creation
Sigma Software
 
False news - false truth: tips & tricks how to avoid them
Sigma Software
 
Анна Бойко, "Хороший контракт vs очікування клієнтів. Що вбереже вас, якщо вд...
Sigma Software
 
Дмитрий Лапшин, "The importance of TEX and Internal Quality. How explain and ...
Sigma Software
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 

SQL Server Deep Dive, Denis Reznik