Microsoft SQL Server internals & architecture

10,639 views

Published on

From noted SQL Server expert and author Kevin Kline - Let’s face it. You can effectively do many IT jobs related to Microsoft SQL Server without knowing the internals of how SQL Server works. Many great developers, DBAs, and designers get their day-to-day work completed on time and with reasonable quality while never really knowing what’s happening behind the scenes. But if you want to take your skills to the next level, it’s critical to know SQL Server’s internal processes and architecture. This session will answer questions like:

- What are the various areas of memory inside of SQL Server?
- How are queries handled behind the scenes?
- What does SQL Server do with procedural code, like functions, procedures, and triggers?
- What happens during checkpoints? Lazywrites?
- How are IOs handled with regards to transaction logs and database?
- What happens when transaction logs and databases grow or shrinks?

This fast paced session will take you through many aspects of the internal operations of SQL Server and, for those topics we don’t cover, will point you to resources where you can get more information.

Published in: Technology

Microsoft SQL Server internals & architecture

  1. 1. SQL SERVER INTERNALS & ARCHITECTURE Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.com Microsoft SQL Server MVP since 2003 Twitter , Facebook, LinkedIn @ KEKline Website: http://KevinEKline.com/, http://ForITPros.com
  2. 2. Tuning blog: http://www.sqlperformance.com/ E-mail ebooks@sqlsentry.com for free copies of our e-books:
  3. 3. 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
  4. 4. OUR TOUR GUIDE Talk nerdy to me, baby!
  5. 5. Buffer Pool Ext’ns 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 SQL- OS SELECT ? Query Tree Query Plan OLE DB ?
  6. 6. 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!
  7. 7. Buffer Pool Ext’ns 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
  8. 8. 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
  9. 9. 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?
  10. 10. Buffer Pool Ext’ns 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 SQL- OS INSERT, UPDATE, or DELETE ? Query Tree Query Plan OLE DB Data Write ? Oooh! So dirty! CheckPoint Lazywriter DD
  11. 11. Buffer Pool Ext’ns 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
  12. 12. SUMMARY

×