Download SNI - SQL Saturday

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SQL Server Internals &
Architecture
Naomi Williams, SQL DBA
Twitter @naomithesqldba
LinkedIn www.linkedin.com/in/nfwilliams/
Tips
#SQLHELP
Get a copy, study it and become a master!
http://www.sqlsaturday.com/498/Sessions/Schedule.aspx
After Party / Networking Event
5:30pm -8:30pm at Jefferson’s
618 Georgia Avenue
Chattanooga, TN 37402
2
Agenda
 ACID
 SQLOS
 Components
of database engine
 Components
of storage engine
 Cache
aging
 Differences
of Hekaton
3
Why is there ACID in my SQL Server?

ACID properties of Transactions
 Atomic
 Consistent
 Isolated
 Durable
4
Welcome to SQL Server! Where does the
path begin?
5
SELECT
SNI (SQL Server Server Network
Interface)
SQL Server Interface
aka API

TDS packets
Protocols

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
SQLOS
SNI (SQL Server Client
Network Interface)
6
SQLOS, Workers and Schedulers

SQLOS creates a set of schedulers upon start equal to the number of logical CPU’s.

Each scheduler manages workers, for every task to execute it’s assigned a worker that is in an idle state.

Workers do not move between schedulers, tasks are never moved between workers. However SQLOS can
create child tasks and assign them different workers.

Tasks can have one of six states

Pending; task is waiting for an available worker

Done; task is completed

Running; task is currently executing

Runnable; task is waiting for the scheduler

Suspended; task is waiting for external event or resource

Spinloop; task is processing a spinlock
7
SQLOS, Workers and Schedulers, cont

Running state

Suspended queue and suspended state

Runnable queue and runnable state
8
SELECT
SNI (SQL Server Server Network
Interface)
SQL Server Interface
aka API

TDS packets
Protocols

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
SNI (SQL Server Client
Network Interface)
Language Event
If query hash does
not exist in Plan
Cache
 Language
 Hash of execution
plan
SQLOS
Buffer Pool
Data Cache
Database Engine
Cmd Parser
Query Tree
Optimizer
Plan Cache
Query Plan
Does the hash exist
in the Plan Cache?
Query Executor
9
YES! Query has plan exists!
Logical Query Tree
Select * from Customers c inner join Orders o on
c.cid=o.cid where o.date=‘2014-12-12’;
Project
(*)
Filter (o.date=‘2014-12-12’)
Inner Join
c.cid=o.cid
Get (customers) as C
Get (orders) as
O
10
SELECT
SNI (SQL Server Server Network
Interface)
SQL Server Interface
aka API

TDS packets
SNI (SQL Server Client
Network Interface)
Protocols

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
SQLOS
Buffer Pool
Language Event
Data Cache
Database Engine
Cmd Parser
Query Tree
Optimizer
Plan Cache
Query Plan
Query Executor
11
Query Optimizer
Parse and logical
query tree
Binding, do they
exist?
Generate physical
query plan
Does it make sense and how can I
get there?
Do the objects exist? Create path in
binary from algebrizer for
optimizer.
Most efficient plan (path) to the
data.
12
Physical Query Plan
13
SELECT
SQL Server Interface
aka API
SNI (SQL Server Server Network
Interface)

TDS packets
SNI (SQL Server Client
Network Interface)
Database Engine
Cmd Parser
Protocols
SQLOS

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
Query Executor
Language Event
Storage Engine
Transaction
Manager
Data File
Retrieves data from
disk to cache
Query Plan
Query Tree
OLE DB
Transaction
Log File
Optimizer
Access Methods
Does Data exist in
Cache?
Buffer Pool
Data Cache
Buffer Manager
14
Plan Cache
Insert, Update, Delete
SQL Server Interface
aka API
SNI (SQL Server Server Network
Interface)

TDS packets
SNI (SQL Server Client
Network Interface)
Cmd Parser
Optimizer
Protocols
SQLOS

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
Query Plan
Query Tree
Query Executor
Language Event
CheckPoint
Transaction
Log File
Storage Engine
Transaction
Manager
Data File
Database Engine
Lock and Log
manager
OLE DB
Buffer Pool
Access Methods
Data Cache
Buffer Manager
15
Plan Cache
WAIT, WAIT WAIT
SOS_Scheduler_Yield
PageIOLatch_x,
Async_IO_Completion
, IO_Completion
Async_Network_IO
Pagelatch_x, Latch_x,
Resource_Semaphore
Locks
LCK_x, LCK_M_x
Writelog,
LogBuffer
Latches
BackupIO
CXPacket
OLEDB
IO_Completion
MSQL_DQ
MSQL_XP
PreEmptive_OS_
ThreadPool
16
WAIT, WAIT WAIT
SQL Server Interface
SOS_Scheduler_Yield
Async_Network_IO
SNI
(SQL
Server
Server
Network
Database Engine
aka API
, CXPacket
Interface)
Cmd Parser

TDS packets
SNI (SQL Server Client
Network Interface)
Writelog,
LogBuffer
Transaction
Log File
Protocols

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
SQLOS
Query Executor
Language Event
PageIOLatch_x,
Async_IO_Completion
, IO_Completion
Data File
LCK_x,
LCK_M_x
Transaction
Manager
Lock and Log
manager
Query Plan
Query Tree
Pagelatch_x, Latch_x,
Resource_Semaphore
OLE DB
Storage Engine
Locks
Optimizer
Buffer Pool
Latches
Access Methods
Data Cache
Buffer Manager
17
Plan Cache
Data Cache and LRU-K
Buffer Pool
Data Cache
ABC
Data File
Free Buffer List
 Every buffer has a
header
 Last two times the
page was
referenced
 Status information
SQLOS
Lazy
Writer
0
0
LAZY WRITER
ABC
AB
18
Plan Cache and LRU
SQLOS
Buffer Pool
Plan Cache
Resource
Monitor
0
0
9 52
ABC
730
ABC
92
AB
19
Hekaton
SQL Server Interface
aka API
SNI (SQL Server Server Network
Interface)

TDS packets
SNI (SQL Server Client
Network Interface)
Transaction
Log File
Cmd Parser
procedures
Optimizerand schema
Protocols
SQLOS

TCP/IP

Shared Memory

Named Pipes

Virtual Interface Adapter (VIA)
Query Plan
Query Tree
Query Executor
In-Memory OLTP
Compiler
Language Event
Memory Optimized
Tables and Indexes
OLE DB
Storage Engine
Transaction
Manager
Data File
Natively compiled stored
Database Engine
Lock and Log
manager
Access Methods
Buffer Pool
Data Cache
Buffer Manager
20
Plan Cache
Summary
 ACID
 SQLOS
 Components
of database engine
 Components
of storage engine
 Cache
aging
 Differences
of Hekaton
21
Related documents