Skip to main content

PostgreSQL

Managed PostgreSQL on SphereDB. Pick an instance type, a version, and a storage size, and ComputeSphere runs the database in your environment. Every service in the environment gets its connection string as DATABASE_URL.

One connection string, end to end
Your serviceapi
Web service, background worker, or cron job.
Secret env var
DATABASE_URL=postgresql://…Injected at deploy time.
PostgreSQLorders
v1625 GB · daily backups

What you configure​

FieldWhat it does
NameLowercase letters, digits, and hyphens, up to 40 characters. Unique in the environment.
Instance typeCPU and memory. See Instance types. The default is Standard 1.
High availabilityNone, or a standby in another zone. From 1 vCPU.
Version16, 17, or 18. The latest is the default.
Storage1 to 2048 GB. Storage grows online and can't shrink.
InjectOn by default: every service in the environment gets DATABASE_URL.

The username, password, and database name are generated for you.

Instance types​

Free and Flex share CPU. Standard and Plus are dedicated; Plus has twice the memory per vCPU. Storage beyond the included amount is billed per GB. Free stays at its included 500 MB.

FamilySizes
FreeOne per engine in each account. 500 MB storage, fixed.
Flex256 MB, 512 MB, or 1 GB of memory.
StandardStandard N: N vCPU.
PlusPlus N: N vCPU, twice the memory of Standard.

csph db instance-types --environment <environment-id> lists every type offered in the environment's region with its monthly price. You can change the type later; the database restarts to apply it.

Regions​

A database runs in the region of the environment you create it in.

RegionCodePlans
US East (Virginia)us-east-1Free, Flex, Standard, Plus
EU (Sweden)eu-north-1Free, Flex, Standard, Plus

Services in the same environment reach the database privately. From outside ComputeSphere, see Connect from outside ComputeSphere. Deploy your apps to an environment in the same region as the database. Backups stay in the same geography as the database: US databases are backed up in the US, EU databases in the EU.

Connect from a service​

With injection on, every service in the environment gets the connection string as DATABASE_URL and restarts to pick it up. If another database in the environment already provides DATABASE_URL, the new one is created without injection, and you choose which services receive it.

Each database has two routes:

RouteUse it for
Pooled (for your app)Your services. Goes through the connection pooler. This is what DATABASE_URL carries.
Direct (for tools and migrations)Session features such as LISTEN/NOTIFY and advisory locks, pg_dump, and schema migrations. Goes straight to the primary.

csph db connection-string <name> prints the pooled string; add --direct for the direct one. Both hosts are private to the environment, and every string uses TLS (sslmode=require).

Connect from outside ComputeSphere​

The database has no public address by default. Two ways to reach it from a laptop, CI, or a BI tool:

WayUse it for
TunnelGUI clients, migrations, and pg_dump from your machine. csph db tunnel orders opens a local port; csph db connect orders opens psql. It uses your CLI login and needs write access to the project. Every session is recorded in the activity log.
Public endpointBI tools and integrations that can't use the tunnel. Off until you turn it on, and only addresses on its allowlist can connect.
csph db public enable orders --allow 203.0.113.7
csph db connection-string orders --public --save-ca

The public endpoint goes straight to the primary; it doesn't go through the connection pooler. The connection string uses sslmode=verify-full, so TLS is verified. Where the database's certificate comes from its own CA, --save-ca saves the CA file in the current directory. Otherwise the string uses sslrootcert=system, which needs libpq 16 or later.

Allowlist changes apply within about 10 seconds, with no restart. Turning the endpoint on or off can take a few minutes. Opening it to every address (0.0.0.0/0 or ::/0) needs --yes-open-to-internet. Your services on ComputeSphere keep using DATABASE_URL; they can't connect through the public endpoint.

When you turn on public access for a database, its hostname now starts with the database's name, for example orders-api-7k2m9q.us-east-1.db.computesphere.com. Hostnames are public: they appear in DNS, so don't put anything sensitive in a database's name. Existing hostnames don't change.

High availability​

OptionWhat you get
NoneOne instance.
StandbyA primary and a standby in another zone, with automatic failover.

A standby needs 1 vCPU or more. Add or change high availability at create time or later; the database restarts to apply it.

Backups and restore​

Nightly base backups plus continuous transaction logs, on every plan. Restore to any moment in the last 7 days. A restore creates a new database and never overwrites the original. Backups stay in the same geography as the database: US databases are backed up in the US, EU databases in the EU.

Create a database​

Honest limits​

  • Storage grows, doesn't shrink. Moving to a smaller disk means a new database and a migration.
  • One Free database per account on each engine, with 500 MB of storage that can't grow. A request to create a Free database with more storage, or to grow one, is refused. Change it to a paid size for more.
  • Changing the instance type or high availability restarts the database. Storage grows without a restart.
  • A deleted database's storage is kept for 7 days, and support can restore it within that window. After that it's gone.
  • No public address by default. Turn on the public endpoint to allow specific addresses.