Top Banner
SQL SERVER INTERNALS & ARCHITECTURE Kevin Kline, SQL Sentry Director of Engineering Services, [email protected] Microsoft SQL Server MVP since 2003 Twitter , Facebook, LinkedIn @ KEKline Website: http://KevinEKline.com/ , http://ForITPros.com
12

Kevin Kline, SQL Sentry Director of Engineering Services, [email protected] Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

Dec 23, 2015

Download

Documents

Nathan Short
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

SQL SERVER INTERNALS & ARCHITECTURE

Kevin Kline, SQL SentryDirector of Engineering Services, [email protected] SQL Server MVP since 2003Twitter , Facebook, LinkedIn @ KEKlineWebsite: http://KevinEKline.com/, http://ForITPros.com

Page 2: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

FOR FRIENDS OF SQL SENTRY• Free Plan Explorer download:

http://www.sqlsentry.net/plan-explorer/

• Free query tuning consultations: http://answers.sqlperformance.com.

• Free new ebook (regularly $10) to attendees. Send request to [email protected].

• SQL Server educational videos, scripts, and slides: http://SQLSentry.TV

• Tuning blog: http://www.sqlperformance.com/

• Monthly eNews tips and tricks: http://www.sqlsentry.net/newsletter-archive.asp

Page 3: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

DROPPING ACID - WHY DOES SQL SERVER DO WHAT IT DOES?

• ACID properties of Transactionso Atomico Consism tento Isolatedo Durable

• Speed, scalability, and

performance; Maximize hardware• Competitive features

Page 4: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

OUR TOUR GUIDE

Talk nerdy to me, baby!

Page 5: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

OK, WE’RE DONE

Relational EngineOptimizer

Query Executor

Cmd Parser

Storage EngineTrans-action Manager

Buffer Manager

Access Methods

Protocol LayerSNI

Data File

T-Log

Buffer Pool- - - - - - - - - - - -Data Cache

- - - - - - - - - - - - Plan Cache

SQL Server Network Interface

TDS

LanguageEvent

SELECT

?

QueryTree

QueryPlan

OLEDB

?

Page 6: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

SQLOS AND SCHEDULERS • 1 Cash Register = 1 Scheduler• Users are assigned

to a thread

Uh oh! The 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!

Page 7: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

Relational EngineOptimizer

Query Executor

Cmd Parser

Storage EngineTrans-action Manager: Log & Lock Mgr

Buffer Manager

Access Methods

Protocol LayerSNI

Data File(s)

T-Log

Buffer Pool- - - - - - - - - - - -Data Cache

- - - - - - - - - - - - Plan Cache

SQL Server Network Interface

TDS

LanguageEvent

SQLOS

?

QueryTree

QueryPlan

OLEDB

DataWrite ?

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

Page 8: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

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

Page 9: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

CACHE AGING & LRU-K BEHAVIOR

getord

Memory

finduser

sp_1 sp_4

16 16

7

2233 02

7

1

564

01

14151312

What about buffer cache?

Page 10: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

BUT WAIT! THERE’S MORE!

Relational EngineOptimizer

Query Executor

Cmd Parser

Storage EngineTransaction Manager: Log & Lock Mgr

Buffer Manager

Access Methods

Protocol LayerSNI

Data File

T-Log

Buffer Pool- - - - - - - - - - - -Data Cache

- - - - - - - - - - - - Plan Cache

SQL Server Network Interface

TDS

LanguageEvent

INSERT, UPDATE, orDELETE

?

QueryTree

QueryPlan

OLEDB

DataWrite ?

Oooh! So dirty!

CheckPoint

Lazywriter

Page 11: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

Relational EngineOptimizer

Query Executor

Cmd Parser

Storage EngineTrans-action Manager: Log & Lock Mgr

Buffer Manager

Access Methods

Protocol LayerSNI

Data File(s)

T-Log

Buffer Pool- - - - - - - - - - - -Data Cache

- - - - - - - - - - - - Plan Cache

SQL Server Network Interface

TDS

LanguageEvent

SQLOS

?

QueryTree

QueryPlan

OLEDB

DataWrite ?

Check Point

Lazywriter

Latches

Locks

HEKATON, A.K.A. IN-MEMORY OLTP

Page 12: Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter, Facebook, LinkedIn @ KEKline.

SUMMARYUnderstanding the internals is as

important as any other bit of info

you might haveRemember:ACID!!!key components of the relational engine?key components of the storage

engine?Key areas of cache?Key areas of the transaction

manager?What two processes conduct

writes?More info?