On this page
Indexing & Storage Engines
Prev: Normalization & Data Modeling | Up: design_patterns | Next: Transactions, ACID & Isolation Levels
Rel: SQL Query Execution Lifecycle, PostgreSQL Indexes & EXPLAIN ANALYZE, MongoDB Indexes
Ref: SQLite — Query Planning & Indexes
Tags: #public #databases #design-patterns #indexing
Contents
- > B-Tree vs. LSM-Tree Storage Engines
- > Composite Indexes & the Leftmost-Prefix Rule
- > Covering, Partial & Expression Indexes
B-Tree vs. LSM-Tree Storage Engines
| Engine | Used By | Strengths | Trade-offs |
|---|---|---|---|
| B-Tree / B+Tree | PostgreSQL, SQLite, InnoDB | Fast point & range reads, predictable latency | Random in-place page writes |
| LSM-Tree | RocksDB, Cassandra, Pebble | High sequential write throughput (memtable + SSTables) | Read amplification & background compaction |
Composite Indexes & the Leftmost-Prefix Rule
An index on (a, b, c) accelerates lookups on (a), (a, b), and (a, b, c) — not (b, c) alone. Put equality columns before range columns (WHERE status = 'paid' AND created_at >= ... -> index (status, created_at)).
Covering, Partial & Expression Indexes
- Covering index: Includes all columns referenced by the query (
INCLUDE (...)in PostgreSQL or trailing columns in SQLite) so the engine answers from the index alone without touching the table heap. - Partial index: Indexes only a hot subset (
CREATE INDEX ... ON jobs(run_at) WHERE state = 'queued'), shrinking index size and write overhead. - Expression index: Indexes derived values (
LOWER(email)) so case-insensitive lookups avoid full scans.
Linked from
- tuts/databases/design_patterns
- tuts/databases/design_patterns/indexing_and_storage_engines
- tuts/databases/design_patterns/normalization_and_data_modeling
- tuts/databases/design_patterns/transactions_acid_and_isolation
- tuts/databases/mongodb/indexes_replica_sets_and_transactions
- tuts/databases/postgresql/indexes_and_explain_analyze
- tuts/databases/sql/joins_and_set_operations
- tuts/databases/sql/query_execution_lifecycle
- tuts/programming/algorithms_and_dsa
- tuts/programming/algorithms_and_dsa/trees_heaps_and_graphs
Related notes
- tuts/databases/mongodb/indexes_replica_sets_and_transactions Linked here; links to this page; shared tags: #databases, #indexing
- tuts/databases/postgresql/indexes_and_explain_analyze Linked here; links to this page; shared tags: #databases, #indexing
- tuts/databases/design_patterns Linked here; links to this page; shared tags: #databases
- tuts/databases/design_patterns/normalization_and_data_modeling Linked here; links to this page; shared tags: #databases
- tuts/databases/design_patterns/transactions_acid_and_isolation Linked here; links to this page; shared tags: #databases
- tuts/databases/sql/query_execution_lifecycle Linked here; links to this page; shared tags: #databases
- tuts/databases/sql/joins_and_set_operations links to this page; shared tags: #databases
- tuts/programming/algorithms_and_dsa links to this page
- tuts/programming/algorithms_and_dsa/trees_heaps_and_graphs links to this page
- tuts/databases shared tags: #databases