20 cards · Public · Shuffle

SQL Indexing & Query Optimization Techniques

Master SQL query performance with this high-yield flashcard deck covering B-tree indexes, execution plans, join algorithms, and SARGable query patterns.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
B-Tree Index
Definition
A self-balancing search tree structure that maintains sorted data to enable logarithmic time complexity () for searches, sequential access, insertions, and deletions. It is the default index type in most relational database management systems (RDBMS).
#2
Term
Clustered Index vs. Non-Clustered Index
Definition
Clustered Index: Determines the physical storage order of data inside the table. A table can have only one clustered index (usually the Primary Key).
Non-Clustered Index: A separate structure containing sorted keys and pointers (Row IDs or clustered keys) back to the actual data rows. A table can have multiple non-clustered indexes.
#3
Term
Composite Index & Leftmost Prefix Rule
Definition
An index created on multiple columns (e.g., (A, B, C)). It follows the Leftmost Prefix Rule, meaning queries can utilize the index if filtering by A, (A, B), or (A, B, C), but not by B or C alone without A.
#4
Term
Covering Index
Definition
An index that contains all the columns requested by a query (in SELECT, WHERE, JOIN, and ORDER BY clauses). Because all required data resides inside the index itself, the database avoids costly physical table lookups (key lookups).
#5
Term
Include Columns (INCLUDE clause)
Definition
A mechanism to add non-key payload columns to the leaf nodes of a non-clustered index without increasing the size of the B-tree search keys.
Example:
sql3 lines
CREATE INDEX idx_user_status 
ON users (status) 
INCLUDE (email, name);
#6
Term
Query Execution Plan
Definition
A sequence of operations generated by the database optimizer detailing how a query will be executed. It reveals operational steps such as Index Seeks, Table Scans, Join algorithms, and sorting costs.
#7
Term
EXPLAIN vs. EXPLAIN ANALYZE
Definition
  • EXPLAIN: Generates and displays the estimated execution plan based on table statistics without running the query.
  • EXPLAIN ANALYZE: Actually executes the query, returning execution times, actual row counts, memory usage, and structural plan details.
#8
Term
Table Scan vs. Index Scan vs. Index Seek
Definition
  • Table Scan: Reads every data page in the entire table ().
  • Index Scan: Reads through all leaf pages of an index ().
  • Index Seek: Uses the B-tree structure to jump directly to specific matching rows ().
Showing 8 of 20 cards in this deck.
Study All Now