Database

MariaDB vs PostgreSQL

Often the app decides this for you: check its docs first, because many self-hosted projects require one specific database. When you do get to choose, PostgreSQL is the better default for new and data-heavy projects, while MariaDB wins on MySQL compatibility and LAMP-stack simplicity. Both are free, mature, and fast enough that for most homelab workloads you will never feel the difference. Here is how to choose when the choice is actually yours.

Updated 2026-06-04 · by

Side by side

MariaDBPostgreSQL
LineageMySQL forkIndependent, from Postgres/Ingres
MySQL compatibilityDrop-in for most MySQL appsNot MySQL-compatible
SQL standardsGoodStronger standards compliance
JSONJSON functions (text-based)JSONB, indexed and fast
Advanced typesFewerRich (arrays, ranges, custom, PostGIS)
Concurrency (MVCC)InnoDB MVCCMature MVCC, strong under writes
Read-heavy web appsVery fast, simpleFast
Complex queriesCapableExcels (CTEs, window functions)

Let the application choose first

Before comparing features, read your app's documentation. A growing number of self-hosted projects support only PostgreSQL: Immich, Authentik, Paperless-ngx, and many others assume it and use Postgres-specific features. Others, especially older PHP applications and WordPress, expect MySQL or MariaDB. Some support both and let you pick at install time.

If the app requires one, that is your answer and the rest of this is academic. The comparison below matters when an app supports both, or when you are choosing a database for something you are building yourself. Do not fight an app's recommended database to satisfy a preference; you will hit untested paths and thin documentation.

MariaDB: the MySQL-compatible workhorse

MariaDB is a fork of MySQL created by its original authors, and it stays largely drop-in compatible. If an app was written for MySQL, MariaDB almost always runs it unchanged, which is why distributions and self-hosted apps adopted it widely. It is the M in countless LAMP stacks.

Its strengths are simplicity and read-heavy web performance. For a WordPress site, a forum, or a typical CRUD app that reads far more than it writes, MariaDB is fast, light, and familiar, with a huge pool of documentation and tooling built up over the MySQL years. Setup is straightforward and the mental model is uncomplicated, which matters when the database is just a dependency you want to forget about.

PostgreSQL: the feature and integrity choice

PostgreSQL is not a MySQL relative; it is its own lineage with a reputation for correctness and depth. It is stricter about data types and constraints, which catches bad data at the door instead of letting it in. For anything where data integrity matters, that strictness is a feature.

It also carries more capability. JSONB stores and indexes JSON efficiently, so you get document-style flexibility with real query performance. Window functions, common table expressions, rich types (arrays, ranges, custom types), and extensions like PostGIS for geospatial data make complex queries and specialized workloads far nicer than on MySQL-family databases. As projects grow in data complexity, this is why so many standardize on Postgres.

Performance, honestly

For homelab-scale workloads, raw performance is rarely the deciding factor, because both are fast enough that your disk, your app code, or your query design will be the bottleneck long before the engine is. Benchmarks that show one beating the other usually reflect a specific workload and tuning, not a universal winner.

The rough generalization: MySQL-family databases have a reputation for very fast simple reads, while PostgreSQL shines on complex queries and heavy concurrent writes thanks to its mature concurrency control. Unless you are running something genuinely large, choose on features and compatibility, not on benchmark numbers you will never reach.

Operations and backups

Both are well-supported and easy to run in a container, which is how most homelabs deploy them. Each app typically gets its own database instance in its compose stack, so you are not running one shared server. That keeps versions and backups isolated per app.

Back them up with the native tools: mysqldump or mariadb-dump for MariaDB, pg_dump for PostgreSQL, on a schedule, plus a copy of the dumps in your normal backup rotation. Do not just snapshot the data directory of a running database and assume it is consistent. A scheduled logical dump is the reliable, restorable approach, and it is worth testing a restore before you need one.

Where MariaDB wins

  • Drop-in compatible with most MySQL applications.
  • Simple, light, and very fast for read-heavy web workloads.
  • Enormous pool of documentation and tooling from the MySQL world.

Where PostgreSQL wins

  • Stronger data integrity and standards compliance.
  • JSONB, window functions, CTEs, and rich types for complex data.
  • Extensions like PostGIS; the default many modern apps require.

Which to pick, by situation

Your situationPickWhy
App requires one specific databaseWhichever it requiresNever fight the app's supported and tested database.
WordPress or a classic LAMP appMariaDBMySQL compatibility and the simplest, most documented path.
New project you are buildingPostgreSQLStronger integrity, JSONB, and room to grow in query complexity.
Data-heavy or complex queriesPostgreSQLWindow functions, CTEs, and rich types make hard queries manageable.
Migrating an existing MySQL appMariaDBDrop-in compatibility means the least friction.

The verdict

When the app dictates a database, follow it. When the choice is yours, default to PostgreSQL for new projects and anything with complex or integrity-sensitive data, thanks to JSONB, rich types, and standards compliance. Choose MariaDB for MySQL-compatible apps, WordPress, and simple LAMP stacks where its compatibility and light footprint are the point. Both are free, mature, and fast enough that you are unlikely to outgrow either at homelab scale.

Choose MariaDB if your app expects MySQL, you run a LAMP stack or WordPress, or you want the simplest compatible path.

Choose PostgreSQL if you are starting fresh or handling complex, integrity-sensitive data and want the richer, stricter engine many modern apps require.

Official links

FAQ

Which database should I use for self-hosting?

Check the app first. Many self-hosted apps require either PostgreSQL or MySQL/MariaDB specifically. When you genuinely get to choose, PostgreSQL is the stronger default for new and data-heavy projects, and MariaDB is best for MySQL-compatible apps and simple LAMP stacks.

Is MariaDB the same as MySQL?

It is a fork of MySQL by the original developers and stays largely drop-in compatible, but the two have diverged over the years in some features and defaults. For most applications MariaDB runs MySQL software unchanged, which is the main reason to use it.

Is PostgreSQL harder to use than MariaDB?

Slightly, mostly because it is stricter and has more features to learn. Day to day, running either in a container is comparable. PostgreSQL's strictness rejects bad data earlier, which feels like friction at first and pays off later.

Can I switch an app from MariaDB to PostgreSQL later?

Sometimes, but it is real work. The two use different SQL dialects and types, so migrating means exporting, transforming, and reimporting data, and only works if the app supports the target database. It is far easier to pick correctly up front.

Which is faster?

It depends entirely on the workload, and for homelab scale both are fast enough that the engine is rarely the bottleneck. MySQL-family databases are known for quick simple reads, PostgreSQL for complex queries and concurrent writes. Choose on features, not benchmarks.

Does Nextcloud work with both?

Yes. Nextcloud supports PostgreSQL and MySQL/MariaDB, and both are fine for it. PostgreSQL is a common recommendation for larger instances, but a well-configured MariaDB runs Nextcloud well too.

How should I back up these databases?

Use logical dumps on a schedule: mariadb-dump or mysqldump for MariaDB, pg_dump for PostgreSQL. Store the dumps with your regular backups and test a restore. Avoid copying a running database's files directly, which can produce an inconsistent backup.

Related on HomelabCompass

← All comparisons