Learning objectives
After reading this article you will be able to:
- Understand the items that make up the bill for a hosted PostgreSQL
- Compare three billing models from well-known providers
- Estimate disk, RAM and monthly cost for your database with SQL queries
PostgreSQL is open source: nobody charges a license fee to use it. You pay for the machine that keeps it running, the disk that holds the data and, depending on the provider, every GB that leaves the network and every copy that is stored. That is why "how much does it cost?" gets answers ranging from zero to hundreds of dollars.
Third-party prices change often, so this guide shows how each provider builds the bill, not its price list. The dollar figures in this article are hypothetical, chosen to keep the math easy. They are not any provider's prices; real prices are on the official pages, so always check the provider's page before you decide.
What goes into the bill for a hosted PostgreSQL?#
Almost every invoice breaks down into the same items:
- Compute (RAM and CPU): the instance that runs the server. It is usually the largest item.
- Disk: billed per provisioned GB per month, even if the database does not fill it yet.
- Copies: automated backups and snapshots take up storage, and the part above the included quota is billed.
- High availability: a standby replica, ready to take over if the primary fails, runs on a second machine.
- Outbound traffic: data leaving the provider's network, such as queries from an app hosted somewhere else.
If you are still choosing the engine, what PostgreSQL is and PostgreSQL vs MySQL help before you look at prices.
How do the common options charge?#
Three well-known providers, three ways to bill:
| Option | Model | How the bill is built |
|---|---|---|
| Supabase Free | no-cost tier | database size cap; pauses after a period of inactivity |
| Supabase Pro | plan + compute | monthly fee with a compute credit that covers the smallest instance; disk above the quota billed per GB |
| Supabase Pro + larger instance | plan + compute | monthly fee plus the instance price, minus the included credit |
| Neon Free | no-cost tier | storage cap per project; suspends when idle |
| Neon Launch | usage-based | compute hours (CU-hours) plus storage per GB-month |
| Amazon RDS | hourly | the instance class rate (db.t4g, db.m7g and others) times the hours it runs; gp3 disk extra |
Current prices: Supabase, Neon and Amazon RDS for PostgreSQL. On RDS, the price varies by region and by deployment option (Single-AZ or Multi-AZ). A month has about 730 hours, so the hourly rate times 730 gives the monthly cost of an always-on instance.
Each model suits a different profile. A flat plan is the easiest to predict. Hourly billing gives fine control over machine size. Usage-based billing, with the database suspended when nobody queries it, is cheap for low-traffic projects, but the first query after a pause waits for the database to wake up.
How do you estimate your database size and cost?#
Start by measuring what you already have. Run this on your current database:
-- total database size
SELECT pg_size_pretty(pg_database_size(current_database())) AS size;
-- the 5 largest tables, including indexes
SELECT relname AS table_name,
pg_size_pretty(pg_total_relation_size(relid)) AS size
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC
LIMIT 5;
-- connections open right now and the configured limit
SELECT count(*) AS connections FROM pg_stat_activity;
SHOW max_connections;Then project the disk: current size, plus monthly growth times the months ahead, plus 30% headroom. A 3 GB database growing 500 MB a month reaches 9 GB in a year and needs about 12 GB provisioned.
With that number, the math gets concrete. Hypothetical example: assuming an instance at $0.05 per hour and disk at $0.25 per GB-month, the instance with the 12 GB provisioned costs 0.05 x 730 + 12 x 0.25 = 36.50 + 3.00 = $39.50 a month, before traffic. On a plan with a quota, such as Supabase Pro, add only the disk above the quota to the monthly fee. On a usage-based model, such as Neon Launch, multiply the active hours by the CU-hour rate and add storage. Then swap the hypothetical figures for the ones on the provider's pricing page.
How much RAM does PostgreSQL need?#
RAM drives performance because PostgreSQL keeps the most used pages in memory. Three settings help with sizing, according to the official documentation:
- shared_buffers: the main cache. The default is typically 128 MB, and the docs suggest starting at 25% of RAM on a dedicated server with 1 GB or more.
- work_mem: memory per sort or hash operation, 4 MB by default. A complex query can use several times that value, in each connection.
- max_connections: typically 100 by default. Each connection is a process with its own memory, so hundreds of idle connections waste RAM.
The rule of thumb: indexes and the most accessed rows should fit in memory. If your app opens too many connections, use a pool instead of buying a bigger instance. The article on the too many connections error shows how.
Is running PostgreSQL on a VPS cheaper?#
On the invoice, often yes: a small VPS costs little and runs PostgreSQL without trouble. See price ranges in how much a VPS costs. The difference is the work that comes with it:
- Installing it, setting up remote access with TLS and closing port 5432 to the internet.
- Applying security updates to the OS and to PostgreSQL.
- Scheduling
pg_dump, shipping the copy off the machine and testing the restore. The steps are in how to back up a database. - Watching for a full disk, which takes the database down without warning.
If you already handle these tasks comfortably, a VPS is the cheapest option per GB of RAM. If you don't, the real cost is the hours spent and the risk of losing data.
What are the hidden costs?#
- Standby replica: on RDS, an instance in Multi-AZ costs about twice the Single-AZ hourly rate, and disk costs more too.
- CPU above the baseline: RDS T4g instances run in Unlimited mode, and usage above the baseline is billed separately, per vCPU-hour.
- Copies above the quota: on RDS, backup storage is not billed up to a limit tied to the size of your provisioned storage in the region, according to the AWS Database Blog; above that, it is billed per GB.
- Traffic: Supabase Pro and Neon's paid plans include an egress quota and charge per GB above it. Keeping the app and the database in the same datacenter cuts both traffic and latency.
To compare with other engines, see how much a cloud database costs.
How to do this on Square Cloud#
Square Cloud offers PostgreSQL hosting from the Standard plan up, always on a recent version. It is native PostgreSQL, without extensions. The Hobby plan does not include databases. You create the database in the dashboard and it is ready in seconds, in the same datacenter as your apps, with an average latency of about 1 ms and mandatory TLS.
Here the price is the plan's, in Brazilian reais, with no charge for bandwidth or requests (fair use policy). Standard costs R$44.99, R$64.99 or R$84.99 a month, with 4, 6 or 8 GB of RAM. That RAM is a pool shared by your applications and databases, and each PostgreSQL database uses at least 1024 MB of it. Each database accepts up to 512 connections, with no pooler in front.
You take manual snapshots whenever you want. Every plan that includes databases also has a daily automatic snapshot: each one is kept for 7 days, and the most recent for up to 30 days. You can restore a snapshot into the same database, another one of the same engine or a new database, or download it as a .zip. See the details in PostgreSQL hosting.
Database hosting
MongoDB, PostgreSQL, MySQL and Redis next to your app
FAQs
Can I host PostgreSQL without paying anything?
There are no-cost tiers with tight limits: on Supabase, the database has a size cap and pauses after a period of inactivity; on Neon, the project has a storage cap and is suspended when idle. They work for learning and prototypes, not for production. Check the current limits on each provider's page.
How much does a small production PostgreSQL cost?
It depends on the model. On Amazon RDS, add the smallest instance's hourly rate times 730 to the provisioned disk; on Supabase, the Pro plan plus any disk above the included quota. Replicas and traffic are added on top. Check the current figures on each provider's page.
How much RAM does PostgreSQL need?
To start, 1 GB serves a small database. The PostgreSQL docs suggest giving about 25% of RAM to shared_buffers on dedicated servers with 1 GB or more, and every open connection uses its own memory.
Does high availability double the price?
Usually it comes close. A standby replica runs on a second machine, with its own disk: on Amazon RDS, the same instance in Multi-AZ tends to cost about twice the Single-AZ price, disk included.
More in Databases
See all 24 articles- How much does database hosting cost?Cloud database hosting costs from zero to hundreds of dollars a month. See what sets the price: instance, disk, traffic, snapshots, and how to estimate yours.
- How to host a database for your appTo host a database, pick an engine, create the instance, store the connection string in an environment variable and test the connection. Step-by-step guide.
- What is Redis used for?Redis is an in-memory data store that keeps key-value pairs and rich data structures. Learn how it works, what it is used for and when not to use it.
- How to back up your databaseBack up MySQL, PostgreSQL and MongoDB with mysqldump, pg_dump and mongodump, then restore the dump. See the commands, how to verify and common mistakes.