🔍 Ctrl+K
🔴 Advanced

Indexing

An Index helps the database locate rows efficiently, like a book index, but adds overhead for writes and storage.

SQL
CREATE INDEX idx_employee_department
ON employees(department_id);
Index concept

Costs: storage, insert/update/delete overhead, maintenance.

Tip
Indexes are not always good — they help reads but slow writes.
🔴 Advanced

Query Optimization

Indexes, Execution plans, Statistics, Join strategy, Filtering, Avoid SELECT *, Partitioning, Rewriting

🟡 Intermediate

EXPLAIN

EXPLAIN shows the database execution plan, revealing how it will scan, join, and filter data to run your query.

SQL
EXPLAIN SELECT * FROM employees WHERE department_id = 10;

Shows how DB will execute query.

🔴 Advanced

Partitioning

Divide large table into smaller partitions (Range/List/Hash). Example orders by year: 2023/2024/2025

Partitioning
orders
├── 2023
├── 2024
└── 2025
🔴 Advanced

Sharding

Distribute data across nodes. Application → Shard 1/2/3

PartitioningSharding
Within a DB systemAcross DB nodes/instances