How to Choose the Right Database for Your Self-Hosted Stack
PostgreSQL, MySQL, MariaDB, SQLite a wrong database choice makes every application slower. Here is how to pick correctly.
Most self-hosted applications list database requirements in their documentation. But understanding why a particular database is recommended helps you make better infrastructure decisions. Choosing wrong leads to slow queries, difficult backups, and painful migrations later.
PostgreSQL: The Default Choice
PostgreSQL is the right default for most self-hosted applications. It supports advanced features that small businesses eventually need: full-text search, JSON columns for flexible data, role-based access control at the database level, and point-in-time recovery. Applications like Nextcloud, Mastodon, and Mattermost choose PostgreSQL for these reasons.
PostgreSQL handles concurrent connections well, supports extensions like PostGIS for geographic data, and has the strongest SQL standards compliance of any open-source database. If an application supports PostgreSQL, use PostgreSQL.
MySQL and MariaDB: When Simplicity Wins
MySQL and its fork MariaDB are simpler to administer and faster for read-heavy workloads. WordPress, Joomla, and many PHP applications default to MySQL. MariaDB has caught up on features and in many cases outperforms MySQL on the same hardware.
Choose MySQL or MariaDB when the application requires it, when you need simple replication for read scaling, or when your team already knows MySQL administration.
SQLite: For Single-User and Embedded Use
SQLite is not a toy. It powers browsers, phones, and embedded devices. For single-user applications like personal wikis (Trilium Notes), recipe managers (Tandoor), and small monitoring dashboards, SQLite is the right choice. It requires zero administration: no server process, no configuration, no user management. Just a file.
Do not use SQLite for multi-user web applications. It handles concurrent writes poorly and will become the bottleneck as your team grows.
Redis: Not a Database, But Essential
Redis is an in-memory data store used for caching, session storage, and message queuing. It is not a replacement for PostgreSQL or MySQL, but it makes them faster. Applications like Nextcloud, Mastodon, and Discourse use Redis to store frequently accessed data, reducing database load by 60 to 80 percent.
If your application documentation mentions Redis, install it. The performance difference is immediately noticeable.
When to Use One Database vs. Many
Each application can use its own database instance, or multiple applications can share one. The trade-off is isolation versus administration overhead. One PostgreSQL instance with separate databases per application is manageable. One PostgreSQL and one Redis instance together cover 80 percent of self-hosted applications.
Want help planning your database architecture? We will design a setup that balances performance, maintenance, and reliability.
More articles
Self-Hosted PIM Solutions Compared
If you sell products anywhere other than one shop, you have a product data problem. You might not call it that yet.
5 Ways to Bypass CGNAT in Brunei
Five technologies let you bypass Brunei residential CGNAT. Here is a detailed comparison of speed, privacy, cost, and complexity for each.
Paperless-ngx: Your Self-Hosted Document Management System
Stop searching through filing cabinets. Paperless-ngx digitises, OCRs, and organises every document your business handles.