24 cards · Public · Shuffle

SQL Indexing & Query Optimization

Master SQL indexing and query optimization to dramatically boost database performance. This deck covers B-tree, Hash, and Bitmap indexes, clustered vs. non-clustered strategies, `EXPLAIN PLAN`, and common anti-patterns for writing lightning-fast queries.

Cards in this deck

(24 cards)

Preview terms and definitions before starting your study session.

#1
Term
What is a SQL Index?
Definition
A database object that provides quick lookup of data in a column or columns of a table. It speeds up data retrieval operations by reducing the number of disk I/O operations required, acting like a book's index.
#2
Term
What is a B-tree Index?
Definition
The most common type of index, organized as a balanced tree structure. It's efficient for range queries, equality lookups, and sorting. Each node contains key-pointer pairs, allowing for fast traversal to locate data. It's the default index type in most relational databases.
#3
Term
When should you use a B-tree Index?
Definition
Ideal for columns frequently used in WHERE clauses, JOIN conditions, ORDER BY clauses, and GROUP BY clauses, especially with high cardinality (many unique values) or when range queries are common.
#4
Term
What is a Hash Index?
Definition
An index that uses a hash function to map key values to locations in a hash table. It's extremely fast for equality lookups (=) because it directly computes the data's location, but inefficient for range queries (>, <, BETWEEN) or sorting.
#5
Term
When should you use a Hash Index, and what are its limitations?
Definition
Best for columns with high cardinality where only equality lookups are performed. Limitations include poor performance for range queries, ORDER BY, and LIKE operations. Not all database systems support them for disk-based tables (e.g., SQL Server doesn't).
#6
Term
What is a Bitmap Index?
Definition
An index that stores a bitmap (a sequence of bits) for each distinct value in the indexed column. Each bit corresponds to a row, indicating whether that row contains the value. Bitmaps can be efficiently combined using bitwise operations for complex queries.
#7
Term
When should you use a Bitmap Index, and what are its limitations?
Definition
Highly effective for columns with low cardinality (few distinct values, e.g., gender, status_flag) and often used in data warehousing for complex WHERE clauses with multiple AND/OR conditions. Not suitable for columns with frequent updates, as updates require rebuilding many bitmaps.
#8
Term
Explain the concept of a Clustered Index.
Definition
A special type of index that dictates the physical order of data rows in the table. The table's data is stored on disk in the order of the clustered index key. A table can only have one clustered index, as data can only be physically sorted one way.
Showing 8 of 24 cards in this deck.
Study All Now