Rationale
GitLab mandates PostgreSQL as the primary OLTP database and enforces standards for database usage, partitioning, and migrations.
Requirements
- Use PostgreSQL as primary database (no other OLTP databases)
- All database changes must go through migration files
- Migrations must be backward-compatible
- Large tables must be partitioned
- Indexes must be added concurrently
- No direct SQL in application code — use ORM or query builder
Database Standards
| Standard | Requirement |
|---|---|
| Engine | PostgreSQL only |
| Migrations | Backward-compatible, reversible |
| Partitioning | Tables > 10M rows |
| Indexes | Concurrent creation, no locks |
| Queries | No N+1, use includes/preload |
| Connections | Pool-based, max 20 per process |
References
- Database Standards Matrix: https://handbook.gitlab.com/handbook/engineering/architecture/abstractions/db_standards_matrix/
- Database Review: https://handbook.gitlab.com/handbook/engineering/architecture/database-review/