NEW TITLE RELEASE ANNOUNCEMENT
See the latest about a temporary release delay on new titles. Learn more.
SQL Server guru and bestselling author Ken Henderson has written the consummate reference to Microsoft SQL Server!
° Contains the most depth and breadth of coverage of any book on SQL Server architecture, internals, and tuning
° Will be a key reference for anyone working with SQL Server, no matter what their skill level
° The latest of the highly-regarded, bestselling Guru's Guides from Ken Henderson
"I can pretty much guarantee that anyone who uses SQL Server on a regular basis (even those located in Redmond working on SQL Server) can learn something new from reading this book."
--David Campbell, Product Unit Manager,
Relational Server Team, Microsoft Corporation
The latest book from the highly regarded and best-selling author Ken Henderson, The Guru's Guide to SQL Server Architecture and Internals is the consummate reference to Microsoft SQL Server. Picking up where documentation and white papers leave off, this book takes an all-inclusive approach to provide the most depth and breadth of coverage of any book on SQL Server architecture, internals, and tuning.
Blending in-depth discussion with practical application, the guide begins with several chapters on the fundamental Windows technologies behind SQL Server, including processes and threads, memory management, Windows I/O, and networking. The focus then moves on to the architectural details of SQL Server and how to practically apply them.
The entire SQL Server product is covered--not just the functionality that resides within the core executable or product features that have been in place for years. SQL Server has matured and broadened substantially with each release, and the author explores the "fringe" technologies that have yet to be covered elsewhere, including Notification Services, Full Text Search, SQLXML, replication, DTS, and a host of others.
Throughout the book, the author uses WinDbg, Microsoft's free downloadable symbolic debugger, to look under the hood of SQL Server. Armed with new debugging and coding skills, readers will be ready to master SQL Server on their own.
The accompanying CD-ROM is packed with additional material, including full source code for the book's 900+ examples, as well as three invaluable tools: DTSDIAG, the VBODSOLE Library, and DTS Package Guru. DTSDIAG allows developers and administrators to simultaneously collect Profiler traces, perform logs, blocking script output, system event logs, and SQLDIAG reports from a specified SQL Server. The VBODSOLE Library features more than twenty new COM-based functions for Transact-SQL, including T-SQL enhancements such as array-manipulation routines, financial functions, string-manipulation functions, and system functions. DTS Package Guru is a .NET-based package editor for SQL Server's Data Transformation Services that allows editing of any modifiable package and supports the automation of mass package changes.
The Guru's Guide to SQL Server Architecture and Internals is the essential guide for database developers and admin- istrators alike, regardless of skill level.
Download the Sample Chapter related to this title.
List of Exercises.
About the Author.
I. FOUNDATIONS.1. Overview.
About the Code.2. Windows Fundamentals.
The Win32 API.
User Mode vs. Kernel Mode.
Processes and Threads.
Virtual Memory vs. Physical Memory.
Knowledge Measure.3. Processes and Threads.
Thread Synchronization.4. Memory Fundamentals.
Shared Memory.5. I/O Fundamentals.
Asynchronous and Nonbuffered I/O.
I/O Completion Ports.
Memory-Mapped File I/O.6. Networking Fundamentals.
Remote Procedure Call.
Knowledge Measure.7. COM.
The Dawn of COM.
COM at Work.
COM and SQL Server.
Knowledge Measure.8. XML.
Simplicity Comes at a Price.
A Brief History of XML.
XML vs. HTML: An Example.
Document Type Definitions.
Converting XML to HTML Using a Style Sheet.
The Document Object Model.
Processing XML with MSXML.
II. SUBSYSTEMS, COMPONENTS, AND TECHNOLOGIES.9. SQL Server as a Server.
SQL Server and Networking.
The SQL Server Executable.
SQL Server's DLLs.
SQL Server I/O.
SQL Server Components.
Knowledge Measure.10. User Mode Scheduler.
UMS Design Goals.
User Mode vs. Kernel Mode Scheduling.
Preemptive vs. Cooperative Tasking.
How UMS Takes Over Scheduling.
The UMS Scheduler.
The UMS Scheduler Lists.
Knowledge Measure.11. SQL Server Memory Management.
The Memory Managers.
Pulling It All Together.
Knowledge Measure.12. Query Processor.
Key Terms and Concepts.
Join Order and Type Selection.
Logical and Physical Operators.
Knowledge Measure.13. Transactions.
The ACID Test.
How SQL Server Transactions Work.
Types of Transactions.
Avoiding Transactions Altogether.
Automatic Transaction Management.
Transaction Isolation Levels.
Transaction Commands and Syntax.
Optimizing Transactional Code.
Knowledge Measure.14. Cursors.
On Cursors and ISAM Databases.
Types of Cursors.
Appropriate Cursor Use.
Transact-SQL Cursor Syntax.
Cursor Stored Procedures.
Optimizing Cursor Performance.
Knowledge Measure.15. ODSOLE.
The sp_OA Procedures.
Automating with ODSOLE.
Automating SQL-DMO by Using ODSOLE.
Using ODSOLE to Automate Custom Objects.
Knowledge Measure.16. Full-Text Search.
Setting Up Full-Text Indexes.
III. DATA SERVICES.17. Server Federations.
Knowledge Measure.18. SQLXML.
Using FOR XML.
Accessing SQL Server over HTTP.
Using URL Queries.
XML Bulk Load.
SQLXML Web Service (SOAP) Support.
Recap. Knowledge Measure.19. Notification Services.
How It Works.
Building Your Own Notification Application.
Knowledge Measure.20. Data Transformation Services.
The Multiphase Data Pump.
The Bulk Insert Task.
The Data Driven Query Task.
Other Types of Transformations.
DTS and Transactions.
Controlling Package Workflow through Scripting.
Parameterized DTS Packages.
The DSO Rowset Provider.
Using DTS to Transform Replication Subscriptions.
Controlling DTS through Automation.
Knowledge Measure.21. Snapshot Replication.
The Snapshot Agent.
Duties of the Snapshot and Distribution Agents.
Remote Agent Activation.
Knowledge Measure.22. Transactional Replication.
The MSrepl_commands Table.
The sp_replcmds Procedure.
The sp_repldone Procedure.
Update Stored Procedures.
Concurrent Snapshot Processing.
Validating Replicated Data.
Knowledge Measure.23. Merge Replication.
Identity Range Management.
IV. UNDOCUMENTED SQL SERVER.24. Finding Undocumented Features.
The syscomments Gold Mine.
Goodies in sysobjects.
Scripting Undocumented and System Objects.
The Profiler Treasure Trove.
Snooping around in the Installation Scripts.
Knowledge Measure.25. DTSDIAG.
V. ESSAYS.Why I Really, Really Don't Like Fish!
When I first started programming computers, I wrote many programs before taking the time to understand the instruction set of the system I was developing on. I got most of these programs working, but debugging complex issues was a painstaking process. As the sophistication of the programs evolved, I eventually hit a wall. When I stepped back and learned the instruction set and underlying architecture of the system, an amazing thing happened: I was able to break through the wall, and I became much more proficient. Frustration and complexity melted away, and, armed with a deep knowledge of the system, I was able to do things that were impossible before.
You've no doubt experienced something similar. Maybe it was while programming computers. Perhaps it was in learning to play a musical instrument--after a short time, you could play scales or simple melodies. However, to truly master an instrument to the point where you can improvise freely requires deep knowledge in both musical theory and proficiency in the instrument. This is the difference between surface knowledge (having the ability to use something) and deep knowledge (knowing how something really works so that you can master it and synthesize new knowledge based on your deep understanding).
Ken Henderson has invested tremendous effort in unlocking the secrets of Microsoft SQL Server, having recently written The Guru's Guide to Transact-SQL (Addison-Wesley, 2000) and The Guru's Guide to SQL Server Stored Procedures, XML, and HTML (Addison-Wesley, 2002). Ken is one of those people who seek deep knowledge. He isn't satisfied in knowing how to operate something--he needs to know how something operates. In his research for The Guru's Guide to SQL Server Architecture and Internals, Ken learned how SQL Server operates, from the ground up--and that is how he presents it.
Part I, Foundations, describes the fundamental substrate on which SQL Server is built. By discussing various Windows services and facilities, this section helps familiarize readers with how SQL Server (or any other high-performance Windows application) communicates with Windows.
Part II, Subsystems, Components, and Technologies, delves into the architecture of SQL Server's core relational engine. Ken discusses the User Mode Scheduler (UMS), a base component of SQL Server that allows it to efficiently scale to thousands of users and process tens of thousands of transactions per second. A highlight of this section is the chapter on the query processor. Ken offers an incredibly clear description of how a query is transformed from SQL text (supplied by an application or user) through parsing, normalization, optimization, and ultimate conversion into a series of physical operators that the execution engine runs to solve the query. Throughout this section Ken describes many of the optimizer's inputs, plan choices, and execution strategies. He also offers a number of "under the cover" tips for how you can peer into this complex portion of the product to determine why the optimizer may have chosen a particular plan to solve your complex query.
Part III, Data Services, discusses the various ways you can interact with SQL Server's core data engine. In this section Ken describes SQL Server's XML facilities and how Data Transformation Services (DTS) can be used to transform and move data into and out of SQL Server. The recently released Notification Services, which can be used to create highly scaled event- and subscription-based data services, is also covered. Finally, Ken describes the various replication technologies supported by SQL Server in great detail.
One obligation in writing a foreword for a book is to provide guidance about who should read it. In this instance, the recommendation is clear: This book is for anyone interested in furthering their existing knowledge of SQL Server into deep knowledge. Some people are naturally inclined to explore any new subject in a deep way. If you are someone who is not satisfied in knowing that something works, but rather you need to know how and why it works, Ken's book will quench your thirst. Perhaps you find that your knowledge of SQL Server, built over a period of time by using the product, no longer offers you explanations to complex issues and questions you face. Ken's book will take you beyond Books Online and into the inner workings of the product. Maybe you simply want to know how SQL Server, a complex and high-performance application, was designed and constructed. Again, The Guru's Guide to SQL Server Architecture and Internals will meet your needs.
I can pretty much guarantee that anyone who uses SQL Server on a regular basis (even those located in Redmond working on SQL Server) can learn something new by reading this book.
David Campbell joined Microsoft in 1994 as a developer on the core storage engine of Microsoft SQL Server. He has been with the SQL Server team since then and is currently the Product Unit Manager of the Relational Server team.
It is hard to believe that it has been ten years since I was offered a job to work at Microsoft to support its new SQL Server Windows NT product. I never thought I would find myself or our product in the position we are today. My previous experience was as a C programmer and database developer on UNIX systems mainly working with Oracle and Ingres. My perception of Microsoft was purely as a desktop company. The only database I had even seen on a PC was dBase. As I contemplated the job offer, I was naturally skeptical. How could Microsoft even create a product that could compete with the biggest names in the database industry? Fortunately for me, Andrea Stoppani, the director of SQL Support for Microsoft in 1993, convinced me that not only would Microsoft and SQL Server be successful but also that I would find a rewarding career with Microsoft because I would have an opportunity like never before: to train, learn, debug, and dig into the internal "nuts and bolts" of a relational database engine.
Ten years later, that promise has held true. In my role as an escalation engineer at Microsoft, I've had to train, learn, debug, and dig into the internal mechanics of the engine that drives SQL Server. Because of that gained knowledge, I've been asked to advise and provide feedback and insight to the development team with each new release. Through these years, I've witnessed an evolution and revolution with this product, from the early years of supporting SQL Server 4.20 for OS/2 when customers on single processor machines were limited to 16MB of RAM to the enterprise-ready, TPC record-breaking SQL Server 2000 Enterprise Server running on a machine with 64CPUs and 512GB of RAM.
The engine itself has clearly evolved from its early origin. The storage engine and query processor for SQL Server 4.20 through SQL Server 6.5 were all based on the original architectural design that came from the port of the Sybase engine on OS/2. During these years, remarkable changes and additions were performed to make the engine run faster and become a reliable, affordable platform for many users looking to deploy database systems. However, these efforts ultimately reached their limits. This is why SQL Server 7.0 was so significant. Microsoft attracted some of the leading developers in the database industry to design and implement a new architecture for the engine, a foundation to build on for years to come.
The changes and evolution have not just been with the SQL Server engine. In fact, in my early years of supporting SQL Server, the engine was the primary focus of the job because the product was pretty much the engine, sqlservr.exe. The development community back then focused its efforts on Visual Basic or C applications using DB-Library communicating over named pipes or IPX/SPX. ODBC was just an idea on Kyle Geiger's computer. Today, it is more common for Microsoft support engineers to deal with multitiered Web-based applications supporting online business retail applications with thousands of users all communicating over TCP/IP. The mind-set of supporting "just the engine" no longer applies. The SQL Server product has expanded to include a rich framework of data services including Multi-Server Job Scheduling, Data Replication, XML, Data Transformation Services, and Notification Services.
As I reflect on the changes to the engine and the core additions that have made it such a popular product, I think about the common questions I get from customers and other Microsoft employees: "How can I learn more about what makes SQL Server so powerful? How can I gain expert knowledge of some of the internals of the SQL Server engine in order to maximize the usage of the product?" My answer is always, "Think like a programmer." To be more specific, "Think like a Windows programmer."
I have learned the importance of gaining a solid understanding of the foundation of technology that the engine uses to perform its work. This includes a range of Windows programming topics such as processes, threads, synchronization, asynchronous I/O, dynamic linked libraries, virtual memory, networking, and COM. Regardless of the various SQL Server releases over the years, learning these topics has been essential to my understanding of the internals of the product. Learning these topics takes much more than just reading about them. You must apply the knowledge and truly understand the meaning behind the concepts. Don't just read about what structure exception handling is--understand why it has become an important feature for the SQL Server engine to use. Part I of this book can help guide you toward that goal. It provides concise, comprehensible coverage of Windows programming fundamentals. But don't just read those chapters. Go through the examples and be sure you understand the answers to the questions in each chapter. Once you master a solid knowledge of these concepts, you will have the right foundation and frame of mind to understand Part II of this book, which covers the internals of the core components that make up the SQL Server engine. Armed with this information, you will be able to broaden and round your skills by understanding the technologies covered in Part III that complement the engine and provide the complete database services product that SQL Server has become.
SQL Server has grown as a technology and as a force in the database industry. The number of high-quality books on this product alone is a leading indicator. When I started at Microsoft in 1993, there were no books on Microsoft SQL Server (and only one was produced within the next year). Today you can search the Web or go to your local bookstore and find dozens of books dedicated to this product ranging from topics on performance tuning to database administration to XML. The development of this book is a testament to the product's success. The book seeks to expand the knowledge of important topics about SQL Server in order to broaden the level of expertise worldwide. With knowledge there is power, and this book is about empowering SQL Server users, developers, and administrators to get the most out of the product.
Bob Ward joined Microsoft in 1993 as a support engineer for Microsoft SQL Server. He is currently an escalation engineer in SQL Server Support.
Download the Index
file related to this title.