Home / Community / SQL Performance Tuning - Indexing, Query Optimization & Execution Plans
Public

SQL Performance Tuning - Indexing, Query Optimization & Execution Plans

Master SQL performance tuning with this comprehensive flashcard deck! Dive into indexing strategies, interpret query execution plans, and learn advanced techniques to optimize your database queries for speed and efficiency.

23 accessible of 23 cards

Card Preview

23 accessible of 23 cards

A quick, read-only look at the deck content.

Term

What is a database index?

Definition

A special lookup table that the database search engine can use to speed up data retrieval. It's a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and storage space to maintain the index data structure.

Term

How do indexes improve query performance?

Definition

Indexes allow the database to quickly locate data without scanning every row in a table. Similar to a book's index, they provide direct pointers to the physical location of data, significantly reducing I/O operations and CPU usage for SELECT queries.

Term

What is the primary trade-off of using indexes?

Definition

While indexes speed up SELECT queries, they add overhead to INSERT, UPDATE, and DELETE operations. Each modification to the indexed table requires the index itself to be updated, consuming additional CPU, I/O, and storage.

Term

Explain a Clustered Index.

Definition

A clustered index determines the physical order of data storage in a table. A table can have only one clustered index because the data rows themselves can only be stored in one order. It's typically built on the primary key.

Term

How does a Clustered Index store data?

Definition

The leaf nodes of a clustered index are the actual data rows of the table, sorted according to the clustered index key. This means that when you retrieve data via a clustered index, you're directly accessing the data itself.

Term

Explain a Non-Clustered Index.

Definition

A non-clustered index does not alter the physical order of table rows. Instead, it creates a separate structure containing the indexed columns and pointers (row locators or clustered index keys) to the actual data rows in the table. A table can have multiple non-clustered indexes.

Term

How does a Non-Clustered Index store data?

Definition

The leaf nodes of a non-clustered index contain the indexed column values and a pointer to the corresponding data row. This pointer can be a Row ID (RID) for tables without a clustered index (heap) or the clustered index key for tables with a clustered index.

Term

What is a Covering Index?

Definition

A covering index (or "index-only scan") is a non-clustered index that includes all the columns required by a query, both in the SELECT list and the WHERE, JOIN, GROUP BY, or ORDER BY clauses. This allows the database to retrieve all necessary data directly from the index without accessing the base table, significantly improving performance.