Databases
How a managed PostgreSQL cluster is sized and billed, how to connect to it, how it is backed up and restored, and how to browse and edit your data from the panel.
Overview
A project's databases are dedicated PostgreSQL clusters running on Cosmoner's own hardware. You pick a version and a size, and pay a fixed monthly price for that capacity — there is no allowance to run out of and nothing metered on top.
Patching is handled for you, and every cluster hands you a connection string when it finishes provisioning.
Always-on
A database is a dedicated PostgreSQL cluster sized by you. There is no sleeping, no allowance and no usage cap: you are buying capacity, and the monthly price is the same whether you use it or not.
You choose:
- Version — the PostgreSQL major version. It is fixed for the life of the cluster, so pick the one your application and its extensions are ready for.
- Size — vCPU, memory and disk. The disk is part of the plan and is included in its price; there is no separate storage line.
Every cluster is a single node, runs in Cosmoner's own data centre in Stockholm, and is reachable from the apps in the same project and, over TLS, from anywhere else. Storage is persistent and survives restarts and maintenance.
Choosing a size
Size from the working set rather than the total data: PostgreSQL is fastest when
the rows you query often fit in memory. The smallest size is meant for
development, staging and side projects, and halves max_connections to 50 —
put a pooler in front of it if your framework opens more.
Move up a size when queries start reaching the disk rather than the cache, or when the data outgrows the disk the size includes.
Changing size
Every size is listed on the cluster's detail page next to your current one, with what changes shown before anything is charged. A change applies prorated against your billing period.
A size whose disk is smaller than the data the database already holds cannot be selected. Free up space first.
Creating one with an app
The app wizard can create a database for a new app in the same step: select
Add a PostgreSQL database when you configure the app. The database is the
same product as one created here, on the same plans and billed the same way,
and it appears in your project's database list. Its connection string is
stored as a project secret, DATABASE_URL by default, and given to the app,
so there is nothing to copy. The app's first deploy waits until the database is
online. See Create an app with a database.
Deleting the app does not delete its database, which keeps its data and its billing until you delete it here.
Connecting
When provisioning finishes, you are shown the host, database name, user, password and a ready-made connection string. The password is shown once — copy it into your secret manager or your app's environment before leaving the page. See the Secrets guide for storing it.
If you lose it, rotate the password from the database's detail page and update whatever was using the old one. Rotating invalidates the previous password immediately.
Each database has two addresses, and the detail page shows both.
From your apps on Cosmoner
Apps in the same project connect to the internal host, which ends in
.svc.cluster.local. The connection never leaves the platform, so it is the
fastest path, and it is the one to put in your app's environment. No other
project can reach it.
From anywhere else
Your laptop, a CI job, a migration tool or an app hosted elsewhere connects to the public host:
pg-<id>.postgres.cosmoner.com:5432Every database is on port 5432; the host name is what selects yours. TLS is
required, and a plaintext connection is refused with a message saying so:
psql "postgresql://app:<password>@pg-<id>.postgres.cosmoner.com:5432/app?sslmode=require"The server certificate is publicly trusted, so a client can verify it without
downloading anything. With libpq 16 or newer, use
sslmode=verify-full&sslrootcert=system; most other drivers verify against the
system's certificates by default once TLS is on.
A few things to know:
- The host name has to reach the server. Clients send it during the TLS
handshake; libpq has done so since version 14, and current drivers for Node,
Python, Go, Java and .NET do too. A client too old for that can name the
database another way: add
options=endpoint%3Dpg-<id>to the connection string, using the first part of your host name. channel_binding=requireis not supported. Leavechannel_bindingat its default,prefer; the password exchange is still protected by TLS.- Idle connections are closed after an hour. Connection pools should validate or recycle connections more often than that — most do by default.
- Cancelling a query works as usual, including Ctrl-C in
psqland statement timeouts set in your driver.
Backups
Every database is backed up, at no extra charge, and there is nothing to switch on. The whole database is included:
- Every change is copied as it is written, away from the server the database runs on.
- A full copy is taken once a night.
- Backups are kept for 7 days, so a database can be restored to any point in time within the last 7 days, not only to last night.
The Overview tab of a database's detail page shows the same under Backups.
Restoring
A restore is done by us: contact support, name the database and the time you want to go back to, and say what you lost.
The backup is restored as a separate copy of your database, beside the live one, and what you need is brought back from it:
- Some rows or a table are copied from it into your live database. The rest of your data is left as it is.
- The whole database can be put back to that time. Everything written after it is lost, so this is only done with your agreement.
Your database keeps its host, user and password throughout, so your connection string keeps working.
Keep your own copy too
Backups protect against mistakes and failures on our side, but they are not a
substitute for your own: as the Terms of Service say,
keeping backups of your data is your responsibility. pg_dump against the
public host (see Connecting) gives you a copy you hold yourself.
Databases on earlier plans
The above applies to every database created today. A database created on an earlier plan has its own backup terms, and its Overview tab shows no Backups section; contact support to ask what applies to it.
Browsing your data
Every database has a Data tab on its detail page, next to Overview. It is there for looking at what the database actually holds without installing a client.
The tab opens a console in two halves. On the left is the table list: the database it is connected to, a schema filter, a search box, and every table and view the database's user can read, with a rough row count against each one. That list stays where it is; the right-hand side switches between two views of whatever you pick.
- Grid — the table's rows, fifty at a time. Click a column heading to sort by it, step through pages from the toolbar, and add, edit or delete rows where the database allows it.
- SQL — an editor for running statements.
Ctrl/Cmd+Enterruns what is in it, and clicking a table in the list writes its name into the query at the cursor instead of opening it. A query's results sort too, though only the rows that came back — sort the whole result withORDER BY.
Rows can be selected. Tick the box at the left of a row, or the one in the
heading to take the whole page; hold Shift while ticking to take everything
between it and your last one. A bar above the rows then says how many are
selected and what can be done with them: Copy as CSV puts them on the
clipboard with a header line, and on a table you may write to, Delete removes
all of them at once. The selection is cleared whenever the rows underneath it
change — another table, another page, another sort.
Row counts, in the list and in the toolbar, are estimates from the database's own statistics rather than exact counts.
The console fills the tab, and when that is not enough room it goes full screen
(Esc leaves it) or opens in a browser tab of its own. On a phone the table
list starts out of the way; the button at the left of the toolbar brings it
back.
Reading and writing
The console can also change data, for members with the developer, admin or owner role on the project.
Rows are editable in place. Add row opens a form with a field per column, Edit opens the same form filled in from the row, and each row has a delete button behind a confirmation — as does a selection of several, which is removed in a single transaction, so either every selected row goes or none of them do. Columns you leave untouched keep their value — or take the column default, when adding a row — so you can change one field without restating the rest. Nullable columns have a Set to null box, since an empty string and a null are different values.
Editing requires a way to name one row rather than every row that looks like it,
which means a primary key, and a table rather than a view. Tables without one
remain browsable; the console says so and points you at the SQL view, where you
write the WHERE clause yourself.
The SQL view runs statements that write. You can send several separated by semicolons, and they all run inside one transaction — if any statement fails, none of them are applied. Each statement reports what it did: rows returned for a read, rows affected for a write. A few statements that act on the database server rather than on your data are refused; run those with your own client.
Viewers see the tables and a read-only SQL view, and no edit controls.
Limits
Two limits keep panel activity from disrupting the application using the same
database: a statement is stopped if it runs longer than a few seconds, and a
write waiting on a lock gives up quickly rather than holding on. Only the first
rows of a large result are returned. Add a LIMIT and a WHERE clause to work
within all three.
Doing this over the API
A database can be created, resized and deleted over the API with a key that has
databases: read, write scope — see the
API Keys guide for issuing one. The endpoints are in the
OpenAPI document, which is generated
from the same schemas the API validates against.
Related: shared databases
Shared databases are a separate, older product: a PostgreSQL database of its own, with its own user, on a server shared with other databases. No new ones can be created — create a database as above instead. Existing shared databases keep working; see the Shared databases reference for connecting to one and deleting it.