Home / Community / SQL Indexing, B-Trees & Query Optimization
Public

SQL Indexing, B-Trees & Query Optimization

Master database performance tuning, execution plans, and B-Tree mechanics with this high-yield computer science flashcard deck. Boost your query optimization skills and conquer indexing interview questions with precision.

20 accessible of 20 cards

Card Preview

20 accessible of 20 cards

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

Term

Clustered Index

Definition

An index that defines the physical storage order of data rows within a table. Because physical data can only be sorted in one way, a table can have only one clustered index. Primary keys create a clustered index by default in most RDBMS engines (e.g., MySQL InnoDB).

Term

Non-Clustered Index

Definition

A separate index structure that stores sorted key values along with pointers (row locators or primary key values) back to the actual data rows. A single table can support multiple non-clustered indexes.

Term

B-Tree vs. B+ Tree

Definition

In a B-Tree, keys and data pointers are stored in both internal and leaf nodes. In a B+ Tree, data/row pointers exist exclusively in leaf nodes, while internal nodes store only search keys. B+ Tree leaf nodes are linked in a doubly-linked list, drastically improving range queries.

Term

B+ Tree Node Splitting

Definition

An operation triggered when inserting a record into a node that has reached its maximum capacity . The node splits into two child nodes, each containing approximately elements, and the median key is promoted to the parent node.

Term

Leftmost Prefix Rule (Composite Indexes)

Definition

For a composite index on columns (A, B, C), the query optimizer can only use the index if the query filtering conditions match from left to right without skipping. A query filtering by (A) or (A, B) utilizes the index, but filtering by (B, C) alone cannot.

Term

Covering Index

Definition

An index that contains all columns requested by a SQL query (both in WHERE, SELECT, and JOIN clauses). This allows the query engine to satisfy the request using an Index-Only Scan without looking up data from the base table.

Term

Table Scan (Sequential Scan)

Definition

A operation where the database engine reads every page and row of a table sequentially. It occurs when no usable index exists, or when the query engine determines that reading the entire table is faster than random index lookups due to low selectivity.

Term

Index Seek vs. Index Scan

Definition

An Index Seek traverses the B-Tree structure directly to locate matching rows in time. An Index Scan reads all or part of the index pages sequentially in time, typically when no leading index key condition is provided.