PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Partial & Expression (Functional) Indexes in PostgreSQL.
senior LevelMost AskedDatabases & SQLPostgreSQL
In Simple Words:
- Partial Index: Indexes only rows matching a
WHEREcondition (CREATE INDEX idx_active ON users (email) WHERE is_active = true;). Saves 90% disk space by indexing only the hot slice of data. - Expression Index: Indexes the result of a deterministic function (
CREATE INDEX idx_lower_email ON users (LOWER(email));), allowing fast case-insensitive lookups without full-table scans.