EasyPerformance & Indexes
Create basic B-tree index
The query
SQL
-- Single column index
CREATE INDEX idx_emp_email ON employees(email);
-- Composite index (column order matters!)
CREATE INDEX idx_emp_dept_sal ON employees(dept_id, salary DESC);
-- Unique index (enforces uniqueness)
CREATE UNIQUE INDEX idx_emp_email_unique ON employees(email);
-- Check existing indexes
SELECT
indexname,
indexdef
FROM pg_indexes
WHERE tablename = 'employees';Note
“B-tree indexes work well for =, <, >, BETWEEN, LIKE 'prefix%'. Column order in composite index matters.