SQL SERVER INTERNALS & ARCHITECTURE Kevin Kline, SQL Sentry Director of Engineering Services, kekline@sqlsentry.net Microsoft SQL Server MVP since 2003 Twitter , Facebook, LinkedIn @ KEKline Website: http://KevinEKline.com/, http://ForITPros.com NEW eBOOK AVAILABLE! Monthly tips and tricks in our eNews at http://www.sqlsentry.net/newsletterarchive.asp Win one of 3 Rookie Experience packages and 3 Ride Along packages from the Richard Petty Driving Experience at Charlotte Motor Speedway after PASS Summit 2013! October 18, 2013. Details at http://sqlsentry.net/webinarlistings.aspx AGENDA • • • • • • • Droppin’ Acid with RDBMSes Our Host and Tour Guide The Life of a Read Statement Dancing for Cache The Life of a Write Statement Summary Q&A TOOLS FROM SQL SENTRY DROPPING ACID - WHY DOES SQL SERVER DO WHAT IT DOES? • ACID properties of Transactions o o o o Atomic Consistent Isolated Durable • Speed, scalability, and • performance • Maximize hardware • Competitive features OUR TOUR GUIDE Talk nerdy to me, baby! OK, WE’RE DONE Query Tree SELECT Language Event Protocol Layer Relational Engine Cmd Parser Optimizer Query Plan SNI Query Executor TDS TLog OLE DB ? Storage Engine Data File Transaction Manager Access Methods Buffer Manager ? SQL Server Network Interface Buffer Pool -----------Data Cache -----------Plan Cache SQLOS AND SCHEDULERS • 1 Cash Register = 1 SchedulerUh oh! The out • Users are assigned of soda! to a thread No problem. Step aside… More syrup for the sodas! Yeah! I’m next in line! Goes to the waiting, i.e. “suspended queue” CACHES? • How long does a page of data or a block of code stay in cache? • Uses a LRU algorithm • Usually performed by the lazywriter, but can also be done by any worker thread after scheduling its own I/O CACHE AGING & LRU-K BEHAVIOR Memory getord 16 14 12 16 13 15 finduser 7 What about buffer cache? sp_1 3 3 1 0 2 7 4 5 6 sp_4 2 2 1 0 BUT WAIT! THERE’S MORE! Query Tree Language Event Protocol Layer Relational Engine Cmd Parser Optimizer Query Plan INSERT, UPDATE, or DELETE SNI Query Executor TDS TLog CheckPoint Data File OLE DB ? Storage Engine Transaction Manager: Log & Lock Mgr Access Methods Data Write Buffer Manager ? Lazywriter SQL Server Network Interface Buffer Pool -----------Data Cache Oooh! So dirty! -----------Plan Cache SUMMARY