Skip to main content

Available Versions

The following versions of PostgreSQL are currently available:
PostgreSQL releases new major versions annually, and supports major versions for 5 years before it is considered end-of-life and no longer maintained.
For databases on EOL versions, Aptible will prevent new databases from being provisioned and mark existing database as DEPRECATED on the deprecation date listed above. While existing databases will not be affected, we recommend end-of-life databases to be upgraded. Restoring a database from a backup will provision a new database that matches the version associated with the backup, even if that version is EOL or Deprecated. The latest version offered on Aptible will always be available for provisioning, regardless of end-of-life date.

Connecting to PostgreSQL

Aptible PostgreSQL Databases require authentication and SSL to connect.

Connecting with SSL

Most PostgreSQL clients will attempt connection over SSL by default. If yours doesn’t, try appending ?ssl=true to your connection URL, or review your client’s documentation. Most PostgreSQL clients will not attempt verification of the server certificate by default, please consult your client’s documentation to enable verify-full, or your client’s equivalent option. The relevant documentation for libpq is here. By default, PostgreSQL Databases on Aptible use a server certificate signed by Aptible for SSL / TLS termination. Databases that have been running since prior to Jan 15th, 2021 will only have a self-signed certificate. See Database Encryption in Transit for more details.

Extensions

The listed extensions alongside those listed in PostgreSQL’s documentation here are available for use. If you require a particular PostgreSQL extension, contact Aptible Support to identify whether it’s a good fit for Aptible.
To replicate PostgreSQL changes into Google BigQuery, see Replicate PostgreSQL to BigQuery with Datastream.
pg_cron lets you schedule recurring database jobs using standard cron syntax. Unlike other extensions, pg_cron requires additional configuration before you can enable it.

Enabling pg_cron

First, add pg_cron to shared_preload_libraries:
Restart your database using the Aptible CLI or Dashboard for the change to take effect.Once the database has restarted, connect to the postgres database and configure pg_cron and max worker settings:
On Aptible, pg_cron must use background workers over localhost connections. The cron.max_running_jobs and max_worker_processes values above should be adjusted to account for the number of concurrently running cron jobs
Restart the database again, then create the extension:
The pg_cron extension must be created in the database cron.database_name is set to. However, jobs scheduled with pg_cron can run queries against any database on the same PostgreSQL instance.

Scheduling jobs

Once enabled, schedule jobs using cron.schedule:
To schedule a job in a specific database:
To view scheduled jobs:
To remove a scheduled job:
pgaudit provides detailed session and object audit logging for PostgreSQL, helping you meet compliance requirements by recording which statements were executed against your database.

Enabling pgaudit

First, add pgaudit to shared_preload_libraries:
Restart your database using the Aptible CLI or Dashboard for the change to take effect.Once the database has restarted, create the extension:

Configuring audit logging

pgaudit supports two modes of logging: session (logs all statements from a session) and object (logs statements that affect specific relations).To enable session audit logging for all DML statements (reads, writes, deletes):
Restart the database for the change to take effect. You can also set pgaudit.log at the role or session level without a restart:
Available log classes include:

Object audit logging

For finer-grained control, assign an auditor role and grant it access only to the tables you want to audit:
After restarting, any SELECT on my_sensitive_table will be logged regardless of the pgaudit.log setting.

Viewing audit logs

pgaudit writes to the standard PostgreSQL log. On Aptible, these logs are available through the Log Drains configured for your environment.
pg_repack lets you remove bloat from tables and indexes without holding exclusive locks during the process.

Enabling pg_repack

Create the extension in the database you want to repack:

Repacking tables

pg_repack is run using its CLI utility. Connect to your database through a database tunnel and run:
To repack all tables in a database:

Common options

pg_repack requires free disk space roughly equal to the size of the table being repacked. Monitor your disk usage before running it on large tables.
pgvector adds vector similarity search to PostgreSQL, enabling you to store embeddings and perform nearest-neighbor queries directly in your database.

Enabling pgvector

Create the extension:

Storing vectors

Add a vector column to your table by specifying the number of dimensions:
Insert vector data as an array-like string:

Querying vectors

Find the 5 nearest neighbors using cosine distance (<=>):
Other supported distance operators:

Indexing for performance

For large datasets, create an index to speed up similarity searches. pgvector supports two index types:HNSW (recommended for most use cases):
IVFFlat (faster to build, good for very large datasets):
Choose the operator class that matches your distance metric: vector_cosine_ops for cosine, vector_l2_ops for L2, or vector_ip_ops for inner product.

Replication

Primary-standby replication is available for PostgreSQL. Replicas can be created using the aptible db:replicate command.

Failover

PostgreSQL replicas can be manually promoted to stop following the primary and start accepting writes. To do so, run one of the following commands depending on your Database’s version: PostgreSQL 12 and higher
PostgreSQL 11 and lower
After the replica has been promoted, you should update your Apps to use the promoted replica as the primary Database. Once you start using the replica, you should not go back to using the original primary Database. Instead, continue using the promoted replica and create a new replica off of it. Aptible maintains a link between replicas and their source Database to ensure the source Database cannot be deleted before the replica. To deprovision the source Database after you’ve failed over to a promoted replica, users with the appropriate roles and permissions can unlink the replica from the source Database. Navigate to the replica’s settings page to complete the unlinking process. See the Deprovisioning a Database documentation for considerations when deprovisioning a Database.

Data Integrity and Durability

On Aptible, PostgreSQL is configured with default settings for write-ahead logging. Committed transactions are therefore guaranteed to be written to disk.

Point-in-time Recovery

Point-in-time Recovery (PITR) is available for PostgreSQL 13 and newer. PITR lets you restore your database to any specific moment in time, protecting against accidental data deletions, corruptions, or other errors. Aptible automatically enables PITR for new PostgreSQL 13+ databases if your Environment’s backup retention policy has at least 1 day of recovery data retention configured. For more details on configuring and using PITR, see Point-in-Time Recovery (PITR).

Configuration

A PostgreSQL database’s pg_settings can be changed with ALTER SYSTEM. Changes made this way are written to disk and will persist across database restarts. PostgreSQL databases on Aptible autotune the size of their caches and working memory based on the size of their container in order to improve performance. The following settings are autotuned:
  • shared_buffers
  • effective_cache_size
  • work_mem
  • maintenance_work_mem
  • checkpoint_completion_target
  • default_statistics_target
Modifying these settings is not recommended as the setting will no longer scale with the size of the database’s container.

Autovacuum

Postgres Autovacuum is enabled by default on all supported Aptible PostgreSQL managed databases. Autovacuum is configured with default settings related to Vacuum, which can be inspected with:
The settings associated with autovacuum can be adjusted with ALTER SYSTEM

Connection Security

Aptible PostgreSQL Databases support connections via the following protocols:
  • For PostgreSQL version 14: TLSv1.2
  • For PostgreSQL versions 15, 16, 17, and 18: TLSv1.2, TLSv1.3