Chapter 5. Data Storage and Query Tuning
The topic of query optimization and tuning could easily fill another book. Indeed, there are many books available already, and I encourage you to read them and master your skills. I will not try to duplicate them here; instead, this chapter will cover some of the most important concepts you need to understand to tune queries.
You cannot master the process of query optimization without understanding the internal index structure and patterns that SQL Server uses to access data. This chapter thus begins with a high-level overview of B-Tree indexes along with seek and scan operations.
Next, I discuss statistics and cardinality estimations, along with ways to read and analyze execution plans.
Finally, I cover several common issues you might encounter during the query tuning process, offering advice on how to address them and index the data.
Data Storage and Access Patterns
Modern SQL Server versions support three data storage and processing technologies. The oldest and most commonly used one is row-based storage. With row-based storage, all table columns are combined into the data rows that reside on 8 KB data pages. Logically, those data rows belong to B-Tree indexes or heaps (which we’ll discuss in a moment).
Starting with SQL Server 2012, you can store some indexes or entire tables in columnar format using column-based storage and columnstore indexes. The data in such indexes is heavily compressed and stored on a per-column basis. This technology ...
Get SQL Server Advanced Troubleshooting and Performance Tuning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.