SlideShare a Scribd company logo
1 of 14
SQL SERVER INTERNALS &
ARCHITECTURE
Kevin Kline, SQL Sentry
Tech Evangelist, SQL Sentry
Microsoft SQL Server MVP since 2003
Twitter , Facebook, LinkedIn @ KEKline
Website: http://blogs.sqlsentry.com/KevinKline
DROPPING ACID - WHY DOES SQL SERVER
DO WHAT IT DOES?
• ACID properties of Transactions
o Atomic
o Consistent
o Isolated
o Durable
• Speed, scalability, and
performance; Maximize hardware
• Competitive features
OUR TOUR GUIDE
Talk nerdy
to me, baby!
OK, WE’RE
DONE
Relational Engine
Optimizer
Query
Executor
Cmd Parser
Storage Engine
Trans-
action
Manager
Buffer
Manager
Access
Methods
Protocol
Layer
SNI
Data
File
T-
Log
Buffer Pool
- - - - - - - - - - - -
Data Cache
- - - - - - - - - - - -
Plan Cache
SQL Server
Network
Interface
TDS
Language
Event
SELECT
?
Query
Tree
Query
Plan
OLE
DB
?
QUERY OPTIMIZATION
Query Processor / Relational Engine
Parser Query Optimizer
Query
Executor
• Optimization is cost-based
o Optimized for worst case scenario: “everything comes from disk”
• The cost numbers may as well be unicorn freckles
o Estimated costs may have no basis in current reality
• Multiple phases (a.ka. “searches”)
o Pre-optimization determines if the plan is “trivial”
o Phase 0: simple plans: e.g. nested loops without parallelism
o Phase 1: quick plans: plans that can be simplified
o Phase 2: full plans: complex queries, parallelism, spills & spools to tempdb
SCHEDULERS, THREADS, AND WAITS
• 1 Cash Register = 1
scheduler
• Users are assigned
to a thread
Uh oh!
Out of
soda!
No problem.
Step aside…
More syrup for
the sodas!
Goes to the waiting, i.e.
“suspended queue”
Yeah! I’m
next in line!
SQL SERVER WAITS
Suspended Scheduler 1
Runnable Scheduler 1
Running Scheduler 1
55 Running
54 CXPACKET
60 LCK_M_S
61 LCK_M_S
53 Runnable
56 Runnable
59 Runnable
Resource Waits
Signal
Waits
52 PAGEIOLATCH_SH
52 Runnable
55 PAGEIOLATCH_SH
53 Running
Relational Engine
Optimizer
Query
Executor
Cmd Parser
Storage Engine
Trans-action
Manager:
Log & Lock
Mgr
Buffer
Manager
Access
Methods
Protocol
Layer
SNI
Data
File(s)
T-
Log
Buffer Pool
- - - - - - - - - - - -
Data Cache
- - - - - - - - - - - -
Plan Cache
SQL Server
Network
Interface
TDS
Language
Event
SQL
OS
?
Query
Tree
Query
Plan
OLE
DB
Data
Write ?
Check
Point
Lazywriter
Latches
Locks
TROUBLE-
SHOOTING WAIT
STATS?
Async_Network_IO
SOS_Scheduler_Yield
Pagelatch_x, Latch_x,
Resource_Semaphore
LCK_x, LCK_M_x
Writelog, Logbuffer
PageIOLatch_x,
Async_IO_Completion,
IO_Completion
MEMORY MANAGER: BUFFER POOL
8
OS
CLR, MPA,
DWA, TS
Buffer Pool
(SPA)
SQL Server 2008 R2 & earlier
Memory
allocations
within
sqlservr
process
space
Max
server
memor
y
OS
DWA, TS
Buffer Pool
(SPA)
SQL Server 2012 & later
Memory
allocations
within
sqlservr
process
space
Max
server
memor
y
Data cache
----------------
Plan cache
----------------
Other caches
Data cache
-~-~-~-~-~-
Plan cache
-~-~-~-~-~-
Other caches
CACHES?
• How long does a page of data or
a block of code stay in cache?
• Uses a LRU algorithm
• Usually performed by the lazy-
writer, but can also be done by
any worker thread after
scheduling its own I/O
PLAN CACHE AGING
get_order
Plan Cache
reset_user
proc11 proc14
1
6
1
6
7
2
2
3
3 0
2
7
1
5
6
4
0
1
1
4
1
5
1
3
1
2
What about
buffer
cache?
BUT WAIT!
THERE’S MORE!
Relational Engine
Optimizer
Query
Executor
Cmd Parser
Storage Engine
Transaction
Manager:
Log & Lock
Mgr
Buffer
Manager
Access
Methods
Protocol
Layer
SNI
Data
File
T-
Log
Buffer Pool
- - - - - - - - - - - -
Data Cache
- - - - - - - - - - - -
Plan Cache
SQL Server
Network
Interface
TDS
Language
Event
INSERT,
UPDATE,
or
DELETE
?
Query
Tree
Query
Plan
OLE
DB
Data
Write ?
Oooh! So
dirty!
CheckPoint
Lazywriter
Relational Engine
Optimizer
Query
Executor
Cmd Parser
Storage Engine
Trans-action
Manager:
Log & Lock
Mgr
Buffer
Manager
Access
Methods
Protocol
Layer
SNI
Data
File(s)
T-
Log
Buffer Pool
- - - - - - - - - - - -
Data Cache
- - - - - - - - - - - -
Plan Cache
SQL Server
Network
Interface
TDS
Language
Event
SQL
OS
?
Query
Tree
Query
Plan
OLE
DB
Data
Write ?
Check
Point
Lazywriter
Latches
Locks
HEKATON, A.K.A. IN-
MEMORY OLTP
bit.ly/1uLrXLN - Ovw
bit.ly/1u4nODQ - WP
SUMMARY

More Related Content

Similar to UG-SQL-Server-Internals-Architecture.pptx

Brk2051 sql server on linux and docker
Brk2051 sql server on linux and dockerBrk2051 sql server on linux and docker
Brk2051 sql server on linux and dockerBob Ward
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewJerry Yang
 
download it from here
download it from heredownload it from here
download it from herewebhostingguy
 
Sql server dba 2012 administration training
Sql server dba 2012 administration trainingSql server dba 2012 administration training
Sql server dba 2012 administration trainingFuturePoint Technologies
 
Building and configuring sql server; Some Recommended Practices.
Building and configuring sql server; Some Recommended Practices.Building and configuring sql server; Some Recommended Practices.
Building and configuring sql server; Some Recommended Practices.John Martin
 
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewNordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewTravis Wright
 
HBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsHBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsMichael Stack
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Webinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Webinar: Unlock the Power of Streaming Data with Kinetica and ConfluentWebinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Webinar: Unlock the Power of Streaming Data with Kinetica and ConfluentKinetica
 
The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019Amit Banerjee
 
Tech-Spark: SQL Server on Linux
Tech-Spark: SQL Server on LinuxTech-Spark: SQL Server on Linux
Tech-Spark: SQL Server on LinuxRalph Attard
 
Modernizing Mission-Critical Apps with SQL Server
Modernizing Mission-Critical Apps with SQL ServerModernizing Mission-Critical Apps with SQL Server
Modernizing Mission-Critical Apps with SQL ServerMicrosoft Tech Community
 
Proving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slobProving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slobKapil Goyal
 
Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Eduardo Castro
 
SQL Server Performance Analysis
SQL Server Performance AnalysisSQL Server Performance Analysis
SQL Server Performance AnalysisEduardo Castro
 
SQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionSQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionTravis Wright
 
DBA Tasks in Oracle Autonomous Database
DBA Tasks in Oracle Autonomous DatabaseDBA Tasks in Oracle Autonomous Database
DBA Tasks in Oracle Autonomous DatabaseSinanPetrusToma
 
SQL Server vNext on Linux
SQL Server vNext on LinuxSQL Server vNext on Linux
SQL Server vNext on LinuxTravis Wright
 
The roadmap for sql server 2019
The roadmap for sql server 2019The roadmap for sql server 2019
The roadmap for sql server 2019Javier Villegas
 

Similar to UG-SQL-Server-Internals-Architecture.pptx (20)

Brk2051 sql server on linux and docker
Brk2051 sql server on linux and dockerBrk2051 sql server on linux and docker
Brk2051 sql server on linux and docker
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
 
download it from here
download it from heredownload it from here
download it from here
 
Sql server dba 2012 administration training
Sql server dba 2012 administration trainingSql server dba 2012 administration training
Sql server dba 2012 administration training
 
Building and configuring sql server; Some Recommended Practices.
Building and configuring sql server; Some Recommended Practices.Building and configuring sql server; Some Recommended Practices.
Building and configuring sql server; Some Recommended Practices.
 
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux OverviewNordic infrastructure Conference 2017 - SQL Server on Linux Overview
Nordic infrastructure Conference 2017 - SQL Server on Linux Overview
 
HBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsHBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbms
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
Webinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Webinar: Unlock the Power of Streaming Data with Kinetica and ConfluentWebinar: Unlock the Power of Streaming Data with Kinetica and Confluent
Webinar: Unlock the Power of Streaming Data with Kinetica and Confluent
 
The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019
 
Oracle golden gate training course
Oracle golden gate training courseOracle golden gate training course
Oracle golden gate training course
 
Tech-Spark: SQL Server on Linux
Tech-Spark: SQL Server on LinuxTech-Spark: SQL Server on Linux
Tech-Spark: SQL Server on Linux
 
Modernizing Mission-Critical Apps with SQL Server
Modernizing Mission-Critical Apps with SQL ServerModernizing Mission-Critical Apps with SQL Server
Modernizing Mission-Critical Apps with SQL Server
 
Proving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slobProving out flash storage array performance using swingbench and slob
Proving out flash storage array performance using swingbench and slob
 
Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008Ajuste (tuning) del rendimiento de SQL Server 2008
Ajuste (tuning) del rendimiento de SQL Server 2008
 
SQL Server Performance Analysis
SQL Server Performance AnalysisSQL Server Performance Analysis
SQL Server Performance Analysis
 
SQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux IntroductionSQL Server 2017 on Linux Introduction
SQL Server 2017 on Linux Introduction
 
DBA Tasks in Oracle Autonomous Database
DBA Tasks in Oracle Autonomous DatabaseDBA Tasks in Oracle Autonomous Database
DBA Tasks in Oracle Autonomous Database
 
SQL Server vNext on Linux
SQL Server vNext on LinuxSQL Server vNext on Linux
SQL Server vNext on Linux
 
The roadmap for sql server 2019
The roadmap for sql server 2019The roadmap for sql server 2019
The roadmap for sql server 2019
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

UG-SQL-Server-Internals-Architecture.pptx

  • 1. SQL SERVER INTERNALS & ARCHITECTURE Kevin Kline, SQL Sentry Tech Evangelist, SQL Sentry Microsoft SQL Server MVP since 2003 Twitter , Facebook, LinkedIn @ KEKline Website: http://blogs.sqlsentry.com/KevinKline
  • 2. DROPPING ACID - WHY DOES SQL SERVER DO WHAT IT DOES? • ACID properties of Transactions o Atomic o Consistent o Isolated o Durable • Speed, scalability, and performance; Maximize hardware • Competitive features
  • 3. OUR TOUR GUIDE Talk nerdy to me, baby!
  • 4. OK, WE’RE DONE Relational Engine Optimizer Query Executor Cmd Parser Storage Engine Trans- action Manager Buffer Manager Access Methods Protocol Layer SNI Data File T- Log Buffer Pool - - - - - - - - - - - - Data Cache - - - - - - - - - - - - Plan Cache SQL Server Network Interface TDS Language Event SELECT ? Query Tree Query Plan OLE DB ?
  • 5. QUERY OPTIMIZATION Query Processor / Relational Engine Parser Query Optimizer Query Executor • Optimization is cost-based o Optimized for worst case scenario: “everything comes from disk” • The cost numbers may as well be unicorn freckles o Estimated costs may have no basis in current reality • Multiple phases (a.ka. “searches”) o Pre-optimization determines if the plan is “trivial” o Phase 0: simple plans: e.g. nested loops without parallelism o Phase 1: quick plans: plans that can be simplified o Phase 2: full plans: complex queries, parallelism, spills & spools to tempdb
  • 6. SCHEDULERS, THREADS, AND WAITS • 1 Cash Register = 1 scheduler • Users are assigned to a thread Uh oh! Out of soda! No problem. Step aside… More syrup for the sodas! Goes to the waiting, i.e. “suspended queue” Yeah! I’m next in line!
  • 7. SQL SERVER WAITS Suspended Scheduler 1 Runnable Scheduler 1 Running Scheduler 1 55 Running 54 CXPACKET 60 LCK_M_S 61 LCK_M_S 53 Runnable 56 Runnable 59 Runnable Resource Waits Signal Waits 52 PAGEIOLATCH_SH 52 Runnable 55 PAGEIOLATCH_SH 53 Running
  • 8. Relational Engine Optimizer Query Executor Cmd Parser Storage Engine Trans-action Manager: Log & Lock Mgr Buffer Manager Access Methods Protocol Layer SNI Data File(s) T- Log Buffer Pool - - - - - - - - - - - - Data Cache - - - - - - - - - - - - Plan Cache SQL Server Network Interface TDS Language Event SQL OS ? Query Tree Query Plan OLE DB Data Write ? Check Point Lazywriter Latches Locks TROUBLE- SHOOTING WAIT STATS? Async_Network_IO SOS_Scheduler_Yield Pagelatch_x, Latch_x, Resource_Semaphore LCK_x, LCK_M_x Writelog, Logbuffer PageIOLatch_x, Async_IO_Completion, IO_Completion
  • 9. MEMORY MANAGER: BUFFER POOL 8 OS CLR, MPA, DWA, TS Buffer Pool (SPA) SQL Server 2008 R2 & earlier Memory allocations within sqlservr process space Max server memor y OS DWA, TS Buffer Pool (SPA) SQL Server 2012 & later Memory allocations within sqlservr process space Max server memor y Data cache ---------------- Plan cache ---------------- Other caches Data cache -~-~-~-~-~- Plan cache -~-~-~-~-~- Other caches
  • 10. CACHES? • How long does a page of data or a block of code stay in cache? • Uses a LRU algorithm • Usually performed by the lazy- writer, but can also be done by any worker thread after scheduling its own I/O
  • 11. PLAN CACHE AGING get_order Plan Cache reset_user proc11 proc14 1 6 1 6 7 2 2 3 3 0 2 7 1 5 6 4 0 1 1 4 1 5 1 3 1 2 What about buffer cache?
  • 12. BUT WAIT! THERE’S MORE! Relational Engine Optimizer Query Executor Cmd Parser Storage Engine Transaction Manager: Log & Lock Mgr Buffer Manager Access Methods Protocol Layer SNI Data File T- Log Buffer Pool - - - - - - - - - - - - Data Cache - - - - - - - - - - - - Plan Cache SQL Server Network Interface TDS Language Event INSERT, UPDATE, or DELETE ? Query Tree Query Plan OLE DB Data Write ? Oooh! So dirty! CheckPoint Lazywriter
  • 13. Relational Engine Optimizer Query Executor Cmd Parser Storage Engine Trans-action Manager: Log & Lock Mgr Buffer Manager Access Methods Protocol Layer SNI Data File(s) T- Log Buffer Pool - - - - - - - - - - - - Data Cache - - - - - - - - - - - - Plan Cache SQL Server Network Interface TDS Language Event SQL OS ? Query Tree Query Plan OLE DB Data Write ? Check Point Lazywriter Latches Locks HEKATON, A.K.A. IN- MEMORY OLTP bit.ly/1uLrXLN - Ovw bit.ly/1u4nODQ - WP