I had always assumed MariaDB would use less RAM than PostgreSQL for small workloads, partly because MariaDB uses a single-process architecture while PostgreSQL uses multiple processes.
I wanted to see whether that assumption held up in practice.
I tested MariaDB 10.11.14 and PostgreSQL 18.6 on a 1-vCPU Linux VM with 512 MiB RAM, then ran additional tests at 256 MiB. No swap.
Peak process memory (PSS) at 512 MiB:
| Configuration | Peak PSS |
|---|
| MariaDB default | 215.9 MiB |
| MariaDB tuned (64 MB InnoDB pool) | 125.6 MiB |
| MariaDB tuned (32 MB InnoDB pool) | 93.6 MiB |
| PostgreSQL default | 180.1 MiB |
| PostgreSQL tuned (16 MB shared buffers) | 50.4 MiB |
A few interesting findings:
- MariaDB's default configuration consumed considerably more memory than I expected.
- Reducing MariaDB's buffer pool and other caches saved substantial memory. The 64 MB configuration also improved throughput over stock in this test.
- PostgreSQL benefited substantially from reduced shared buffers and query memory.
- At 256 MiB, only the most conservative MariaDB configuration completed the workload. Both tuned PostgreSQL configurations completed their respective tests.
- A single-process architecture does not necessarily translate into a smaller memory footprint.
The configurations that worked best for my use case:
MariaDB 10.11.14 - lowest-memory configuration:
[mariadbd]
innodb_buffer_pool_size=32M
key_buffer_size=8M
aria_pagecache_buffer_size=16M
max_connections=10
PostgreSQL 18.6 - lowest-memory and best-performing configuration in my tests:
shared_buffers = '16MB'
work_mem = '1MB'
maintenance_work_mem = '16MB'
max_connections = 5
superuser_reserved_connections = 1
jit = off
max_parallel_workers_per_gather = 0
max_parallel_workers = 0
Important limitations: These were short, read-only experiments with four active connections, different datasets and SQL workloads, and one measured run per configuration. The numbers are not an apples-to-apples database benchmark, and process PSS does not represent total system memory consumption.
My main takeaway is that both databases can run on surprisingly small machines if configured appropriately. For small web applications, I prefer starting with a conventional server database and modest resource settings, then increasing the allocations as the application grows rather than migrating databases later.
Full article with methodology, configurations, and results:
https://pvrlabs.xyz/java-performance/experiments/mariadb-postgresql-small-vps.html
I'm curious how others approach this. Do you start with conservative database settings on small instances and scale them up later, or prefer leaving the defaults alone until memory becomes a problem?