A small VPS can make a database's default configuration feel much larger than expected. I wanted to see how far ordinary, documented configuration changes could take MariaDB and PostgreSQL on machines with 256 MiB or 512 MiB of allocated RAM.

The short answer: both databases completed a read workload at 512 MiB, but their process memory differed considerably. At 256 MiB, the stock MariaDB configuration and one lightweight profile were killed by the kernel. A smaller MariaDB profile completed, as did both lightweight PostgreSQL profiles in a separate experiment.

  • At 512 MiB, every configuration completed the workload. Peak process memory (PSS) ranged from 215.9 MiB for stock MariaDB down to 50.4 MiB for tuned PostgreSQL, and the leanest PostgreSQL profile also had the best throughput and p95s in its run.
  • At 256 MiB, stock MariaDB and one MariaDB tuning were OOM-killed; the 32 MiB-pool MariaDB profile and both tuned PostgreSQL profiles completed.
  • These are single short runs of a read-only workload, database-only, and the two databases did not execute identical work.

Setup

Both experiments ran on local x86-64 virtual machines (Lima/VZ on macOS with Ubuntu 24.04 guests, Linux 6.8), each with one vCPU, no swap and about 456 MiB of usable RAM at the 512 MiB allocation. The MariaDB run used the Ubuntu MariaDB 10.11.14 package with a 520,000-row fixture of about 164 MiB; the PostgreSQL run used PostgreSQL 18.6 with a 222 MiB fixture. Each variant ran 20 seconds of warm-up and a 50-second measured window with four persistent connections, and memory counters were sampled about once per second. The tuned configurations are Profile A and Profile B in this article; the experiment repositories call them Theory A and Theory B.

These are database-only experiments, not complete application deployments. They are short, single runs on local VMs, and the two databases did not execute identical work. The MariaDB experiment and PostgreSQL experiment contain the configurations, method and measurements.

What happened at 256 MiB

The 256 MiB guest had only about 204 MiB of usable memory and no swap. Stock MariaDB started, but the kernel killed it before the measured query phase. Profile A, which reduced several caches, was also killed during measurement. Profile B, with a smaller InnoDB buffer pool, completed the workload without an OOM kill or swap.

In a separate PostgreSQL follow-up at 256 MiB, both lightweight profiles completed their measured workloads. The PostgreSQL stock configuration ran out of memory during a preparation smoke run, so it does not provide a completed stock comparison.

This is a useful viability signal, not a recommendation to deploy either database alongside an application on 256 MiB. The database had the VM to itself. An application, connection pool, monitoring and operating system activity all need memory too.

At 512 MiB, MariaDB had room to trade memory for performance

All three MariaDB profiles completed on the 512 MiB guest. The Ubuntu package baseline used a 128 MiB InnoDB pool, 128 MiB MyISAM key cache, 128 MiB Aria cache and a 151-connection limit. Its peak sampled process PSS was 215.9 MiB.

MariaDB Profile A reduced the InnoDB pool to 64 MiB, the key cache to 8 MiB and the Aria cache to 16 MiB, and capped connections at 10. It also used loopback binding and UTC. Peak PSS fell to 125.6 MiB, and A had the highest completion rate among the MariaDB configurations in this run. That saving belongs to the whole profile, not a single setting.

Profile B kept A's settings but reduced the InnoDB pool to 32 MiB. It reached 93.6 MiB peak PSS, about 32 MiB below A, with lower throughput and higher query p95s in this workload. If memory is the immediate constraint, that headroom may be useful. If the machine has room, A is a reasonable starting point to test against the application's real queries.

PostgreSQL used less process memory in these runs

Both lightweight profiles set a five-connection limit, disabled JIT and parallel query workers, and retained fsync and autovacuum. PostgreSQL A used 16 MiB shared buffers and 1 MiB work_mem with the default worker I/O method. PostgreSQL B used 32 MiB shared buffers, default work_mem and synchronous I/O. They are different bundles; unlike MariaDB A and B, they do not differ by only one setting.

Peak process PSS on 512 MiB VMs: MariaDB stock 215.9 MiB, A 125.6, B 93.6; PostgreSQL stock 180.1, A 50.4, B 79.7.
Peak sampled process PSS on 512 MiB VMs. The databases ran separate workloads, once per profile.

In these runs PostgreSQL A peaked at 50.4 MiB PSS, compared with 125.6 MiB for MariaDB A and 93.6 MiB for MariaDB B. PostgreSQL Profile A used the least process memory of the six configurations measured at 512 MiB.

DatabaseProfileQueries/sPoint p95Range p95Aggregate p95
MariaDBStock788.33.15 ms4.27 ms93.57 ms
MariaDBA933.63.05 ms4.26 ms92.02 ms
MariaDBB873.23.36 ms4.68 ms103.70 ms
PostgreSQLStock863.22.90 ms1.95 ms98.55 ms
PostgreSQLA1,056.22.64 ms1.93 ms74.25 ms
PostgreSQLB860.82.92 ms2.09 ms103.18 ms

The workloads had a similar shape: four active connections, mostly point lookups, some short ranges and a smaller share of sorts. The two experiments were built and run separately, each with its own fixture and query driver, rather than as a controlled head-to-head: MariaDB's table and indexes occupied about 164 MiB, versus about 222 MiB for PostgreSQL. The numbers are useful context, not proof that PostgreSQL is universally lighter or faster. Each result is one fixed-order run; cache carry and run-to-run variation can affect it.

PSS accounts for shared process pages proportionally, but it is not total VM memory. In particular, filesystem cache and other operating-system memory also need room. Neither experiment included an application, and the read-only measured phases do not characterize write durability costs.

Copyable starting configurations

The two strongest profiles from these runs, as drop-in files. Both are starting points sized for this workload, not recommendations for every deployment; check your package for later overrides and measure your own workload afterwards.

MariaDB Profile A

Save as /etc/mysql/mariadb.conf.d/99-light.cnf and restart MariaDB:

[mariadbd]
bind-address=127.0.0.1
innodb_buffer_pool_size=64M
default_time_zone='+00:00'
key_buffer_size=8M
aria_pagecache_buffer_size=16M
max_connections=10

Loopback binding matches this database-only setup; durability and all remaining settings stay at package defaults. Profile B is the same file with innodb_buffer_pool_size=32M.

PostgreSQL Profile A

Add to the active cluster configuration (find it with SHOW config_file; in psql) and restart the cluster; max_connections and shared_buffers require a restart:

max_connections = 5
superuser_reserved_connections = 1
jit = off
max_parallel_workers_per_gather = 0
max_parallel_workers = 0
shared_buffers = '16MB'
work_mem = '1MB'
maintenance_work_mem = '16MB'

The five slots include the reserved superuser slot, leaving at most four client connections; size application pools and administration access accordingly. work_mem is per operation, not a global cap, and a low value can spill large sorts to disk. Profile B instead sets shared_buffers = '32MB', keeps default work_mem and uses io_method = 'sync'.

What I would do on a small VPS

Start with the database your application needs, then measure the whole deployment under representative traffic. Check effective package settings, set a connection limit that accommodates the application pools and administration, and leave headroom for the operating system. Small caches can make a configuration viable, but they can also change latency and disk traffic.

For a 512 MiB database-only starting point, MariaDB A balanced memory and throughput in this run, while B bought additional headroom. PostgreSQL A was notably compact on its separate workload. Neither result replaces a workload-specific test, especially when the database shares the VM with an application or handles writes.