---
title: "PostgreSQL"
description: "Create and operate managed PostgreSQL databases on Miget."
---
PostgreSQL is a powerful, open-source, object-relational database management system used globally by some of the world’s best technology companies. Miget’s managed PostgreSQL offering makes it easy to use PostgreSQL in a secure, reliable, and completely hands-off way.
## Creating a Database
You can provision PostgreSQL in two ways: as a standalone service or as an addon attached to an existing app.
### Standalone Service
1. Open [app.miget.com](https://app.miget.com) and go to **Services**.
2. Click **Create your first service** (or **New service**) and pick **PostgreSQL**, then choose **Configure**.
3. Assign a **Resource** (the compute pool where the database will run) and give the service a descriptive **Name/Label**.
4. Customize the database:
- Pick the PostgreSQL version (see supported list below).
- Toggle **Public Access** on/off depending on whether you need external connectivity.
- Optionally add project-scoped environment variables such as `DATABASE_URL` so every app in the project can reuse the connection string.
### App Addon
If you already have an app, open it and select **Addons → PostgreSQL → Add**. The same configuration form appears with identical options (version, public access, environment variables). When created as an addon, Miget automatically injects app-level environment variables so your app can immediately consume the connection details.
Not everyone sees every control here. Deleting a database and resetting it need
the `manage` permission; adding one, its public access, its backups and its
replicas do not. See [why a role does not see
something](/overview/user-management/workspaces-members-roles#why-a-role-does-not-see-something).
Select PostgreSQL version, currently Miget supports:
* 18.x
* 17.x
* 16.x
* 15.x
* 14.x
* 13.x (legacy, scheduled for decommission)
You receive the latest patch for the chosen major line, e.g., 18.1 for the 18.x track.
**PostgreSQL 13 is deprecated.** Provisioning new PostgreSQL 13 databases is discouraged, and Miget will decommission support for it soon. If you run a PostgreSQL 13 database today, plan a migration to a newer major version. See [Upgrading to a New PostgreSQL Major Version](#upgrading-to-a-new-postgresql-major-version) for the process.
Select RAM size and Disk space for your database. RAM size and Disk space count toward your Miget plan's limits.
The database storage limit applies to all storage the PostgreSQL database needs, including caches, indices, etc.
Backup storage does not count toward your Miget plan's storage limit.
### From app.json
Declare the database in your repository's [`app.json`](/overview/app-json) and Miget provisions it as an addon on your next build, before the release phase runs:
```json app.json
{
"addons": ["heroku-postgresql:essential-1"]
}
```
This creates PostgreSQL 16 with 0.5 CPU, 512 Mi RAM, and 10 Gi disk, and sets `DATABASE_URL` on your app. `postgres` alone gives you the `essential-0` tier (0.2 CPU, 256 Mi RAM, 1 Gi disk). See [app.json addons](/overview/app-json#addons) for every tier and its size.
## Memory Profiles
Managed Miget's PostgreSQL instances are pre-configured with memory profiles. Miget PostgreSQL plans ranging from 128 Mi to 8 Gi.
If you need more - we can always work with you to provide a custom plan; just contact us at [hello@miget.com](mailto:hello@miget.com)
| RAM | `max_connections` | `shared_buffers` | `effective_cache_size` | `maintenance_work_mem` | `work_mem` |
|:------ | :---------------- | :--------------- | :--------------------- | :--------------------- | :--------- |
| 128 Mi | 97 | 32MB | 96MB | 8MB | 84kB |
| 256 Mi | 97 | 64MB | 192MB | 16MB | 168kB |
| 512 Mi | 97 | 128MB | 384MB | 32MB | 337kB |
| 1 Gi | 97 | 256MB | 768MB | 64MB | 675kB |
| 2 Gi | 97 | 512MB | 1536MB | 128MB | 1351kB |
| 4 Gi | 97 | 1GB | 3GB | 256MB | 2702kB |
| 8 Gi | 197 | 2GB | 6GB | 512MB | 2661kB |
## Connecting to Your Database
How you connect to your database depends on your code: some frameworks expect a single connection string or URL in an environment variable, while others need multiple connection parameters in a configuration file.
When you add a PostgreSQL addon, Miget will automatically generate and set a `DATABASE_URL` variable with a value like `postgres://fcsn1vo8:PXERTRrlRhTb@postgres-t7hvtfin.migetcyy.eu-east-1.migetapp.internal:5432/t7hvtfin`. This means you don’t have to manually configure your database connection-Miget handles it for you, ensuring the connection details are securely stored and easily accessible by your application during runtime.
### Connecting from Apps on Miget
Using internal connection values is the recommended way for workloads running inside Miget. The hostname, username, database, and password are displayed on the service or addon page:
An internal connection string that looks like `postgres://fcsn1vo8:PXERTRrlRhTb@postgres-t7hvtfin.migetcyy.eu-east-1.migetapp.internal:5432/t7hvtfin` is also available if needed. Many database frameworks allow (or require) a connection string instead of individual connection parameters.
### Connecting from Outside Miget
If **Public Access** is enabled, the **Connection Information** panel lists:
- An **External Connection URL** (standard PostgreSQL URI)
- A ready-to-run **psql command**, for example:
```bash
PGPASSWORD=TMyqX12mvlZy psql -h postgres-service-umlwa.db.eu-east-1.onmiget.com -U l9vhbpir ksm7vspn
```
Use these values for local tools, migrations, or CI jobs.
## Streaming Replication
Miget supports PostgreSQL streaming replication for high availability and read scaling. You can create read replicas of your primary database and promote them when needed.
### Creating a Replica
You can add a read replica to any PostgreSQL database - both standalone services and app addons.
1. Open your PostgreSQL service or addon
2. Go to the **Instances** or **Replication** section
3. Click **Create Replica**
4. The replica streams changes from the primary in real time
Replicas share the same PostgreSQL version as the primary and receive all write operations automatically through streaming replication.
### Promoting a Replica
When you need a replica to become the new primary (for example, during a planned failover or region migration):
1. Go to the replica's details page
2. Click **Promote to Primary**
3. The replica stops replicating and becomes an independent, writable database
Promoting a replica is irreversible. The promoted replica becomes an independent database and no longer receives updates from the original primary.
### External Replicas
You can also connect external PostgreSQL replicas for cross-region setups or migration scenarios. Use the **Promote External** option to make an externally connected replica the new primary.
### Disk Usage Monitoring
Track disk usage per database instance from the service details page. This helps with capacity planning and identifying when you need to increase your storage allocation.
## Backups
We take complete database backups **every day** and **retain all backups for at least 7 days**.
## Disk Space
We offer PostgreSQL plans ranging from 128 Mi to your current Miget plan's limit of storage per instance. The database storage limit applies to all storage the PostgreSQL database needs, including caches, indices, etc. Backup storage does not count toward your plan’s storage limit.
If you need more - we can always work with you to provide a custom plan; just contact us at [hello@miget.com](mailto:hello@miget.com)
## Metrics
### Dashboard
You can view database metrics any time in the Miget Dashboard. Currently, we support the following:
| Metric | Description |
|:--------- | :------------------------ |
| CPU | The amount of CPU used |
| Memory | The amount of memory used |
You can see these metrics under Miget Overview page.
## Database Versions & Upgrades
Miget currently supports PostgreSQL 13, 14, 15, 16, 17, and 18. You can select the major version of your database at creation time, after which it cannot be changed. PostgreSQL 13 is in legacy status and scheduled for decommission, so new databases should choose a newer major version.
We will periodically upgrade the minor version of your databases to apply the latest security fixes. For any maintenance periods that require downtime, we email you ahead of time. We also allow you to run the maintenance yourself, simply stop and start your database from the Miget Dashboard. A newer Docker image of PostgreSQL will run your database.
### Upgrading to a New PostgreSQL Major Version
Here’s an overview of the process for upgrading your database to a newer PostgreSQL version:
* Set up a new database instance with the desired version.
* Stop any applications that write to the current database to avoid discrepancies between the existing data and the backup.
* Create a backup of your current database.
* Restore the backup to the new database instance.
* Update your applications to connect to the new database and resume their operation.
Depending on your application architecture, this upgrade may involve some downtime.
You can back up your database schema and table data using the `pg_dump` command. Replace variables with your connection details (internal or public hostname):
```
PGPASSWORD={PASSWORD} pg_dump -h {DATABASE_HOST} -U {DATABASE_USER} {DATABASE_NAME} \
-n public --no-owner > database_dump.sql
```
You can then restore this data to your new database:
```
PGPASSWORD={PASSWORD} psql -h {DATABASE_HOST} -U {DATABASE_USER} {DATABASE_NAME} < database_dump.sql
```
## Sleeping when idle
On Usage Billing, a PostgreSQL database can hibernate while nobody uses it: a service on its own after 15 minutes with no client connected, a database on an application whenever its application sleeps. Set it in the database's **Settings -> General** - see [Sleeping when idle](/pricing/usage-billing#sleeping-when-idle).
## Deleting Databases
If you choose to delete a PostgreSQL instance, we do not keep any backups or snapshots of your data. Be sure to download a backup before proceeding with deletion.
## PostgreSQL Extensions
Miget PostgreSQL databases come with a curated set of popular extensions baked into the image. Some are pre-installed in every new database; others you can enable on demand from any SQL client.
### Pre-installed in every database
These extensions are created automatically when your database is provisioned (no action required):
| Extension | Purpose |
|:--------- |:------- |
| `vector` | Vector similarity search (pgvector) for embeddings and ANN indexes |
| `uuid-ossp` | UUID generation (v1, v3, v4, v5) |
| `pgcrypto` | Cryptographic functions and `gen_random_uuid()` |
| `pg_stat_statements` | Query execution and plan statistics |
| `pg_trgm` | Trigram-based text similarity and indexing |
| `hstore` | Key-value pairs as a column type |
| `citext` | Case-insensitive text |
| `unaccent` | Diacritic-removing text-search dictionary |
| `btree_gin` | GIN indexes on B-tree-style scalar types |
| `btree_gist` | GiST exclusion constraints (e.g., non-overlapping time ranges) |
| `ltree` | Hierarchical path queries (org charts, taxonomies, comment trees) |
You can confirm what is currently installed in your database with:
```sql
\dx
```
### Available on demand
Run `CREATE EXTENSION` from any SQL session (`psql`, `pgcli`, your app's ORM) to add any of these to your database:
| Extension | Purpose |
|:--------- |:------- |
| `pgmq` | Lightweight in-database message queue (similar to AWS SQS) |
| `ip4r` | IPv4/IPv6 range types with GiST indexing |
| `pg_uuidv7` | UUID v7 (time-sortable) |
| `pg_hashids` | Short opaque IDs (YouTube-style) |
| `pg_ivm` | Incremental materialized views |
| `pg_jsonschema` | JSON Schema validation in `CHECK` constraints |
| `pg_graphql` | GraphQL API over your tables (PostgreSQL 14+) |
| `pg_session_jwt` | JWT session management in-database (PostgreSQL 14+) |
| `temporal_tables` | System-versioned tables with full history |
| `hypopg` | Hypothetical indexes: try indexes in `EXPLAIN` without creating them |
| `hll` | HyperLogLog data type for approximate distinct counts |
| `pg_cron` | Cron-style job scheduler that runs inside the database |
| `pg_partman` | Automated time-range and ID-range partitioning |
| `pg_repack` | Online table reorganization with minimal locking |
| `pg_squeeze` | Background worker that reclaims table bloat without an exclusive lock |
| `pg_failover_slots` | Keeps logical replication slots usable after a failover |
| `orafce` | Oracle-compatible functions and operators |
| `pg_hint_plan` | Planner hints via SQL comments |
| `postgis` | Spatial types and operations |
| `postgis_topology` | PostGIS topology model |
| `postgis_raster` | PostGIS raster types |
| `pgrouting` | Graph routing on PostGIS geometries |
| `vectorscale` | DiskANN index for high-recall vector search (requires `vector`) |
| `plv8` | JavaScript stored procedures (V8 engine, sandboxed) |
| `plperl` | Perl stored procedures (sandboxed) |
| `pltcl` | Tcl stored procedures (sandboxed) |
| `timescaledb` | Time-series data with hypertables, continuous aggregates, and compression (Apache build) |
| `anon` | Data anonymisation and masking (useful for shipping prod snapshots to staging). Requires PostgreSQL 14+ |
| `pgaudit` | Session and object audit logging for compliance |
| `pg_tle` | Trusted Language Extensions: ship an extension in SQL or JavaScript without server access |
| `pg_net` | Async HTTP client from SQL (libcurl-based, good for webhooks) |
| `http` | Synchronous HTTP requests from SQL |
| `rum` | Alternative full-text-search index with richer ranking and phrase queries (an upgrade over GIN for `tsvector`) |
| `wal2json` | Logical-decoding output plugin that emits row changes as JSON (CDC pipelines) |
| `pg_qualstats` | Predicate statistics to drive index recommendations |
| `pg_stat_kcache` | Per-query CPU and physical I/O, measured at the kernel |
| `pg_show_plans` | Execution plans of queries that are still running |
| `set_user` | Audited privilege escalation, with the original role logged |
| `credcheck` | Password and credential policy enforcement |
| `pgtap` | Unit-test framework for PostgreSQL |
| `plpgsql_check` | Static analysis (lint and type-check) for `PL/pgSQL` functions |
Example:
```sql
CREATE EXTENSION postgis;
CREATE EXTENSION pg_uuidv7;
CREATE EXTENSION vectorscale; -- depends on the pre-installed `vector`
```
Some of these normally need a library loaded at server start, which elsewhere means editing `postgresql.conf` and restarting: `timescaledb`, `pg_cron`, `pgaudit`, `pg_net`, `pg_tle`, `anon`, `pg_squeeze`, `pg_partman`, `pg_failover_slots`, `pg_stat_kcache`, `pg_hint_plan`, `pg_qualstats`, `pg_show_plans`, `set_user` and `credcheck`. Miget preloads them for you, so `CREATE EXTENSION` is the only step and their background workers are already running.
To run these from outside Miget, start a `psql` session using the connection details from your database's **Connection Information** panel:
```bash
PGPASSWORD={PASSWORD} psql -h {DATABASE_HOST} -U {DATABASE_USER} {DATABASE_NAME}
```
Extension versions may vary slightly between PostgreSQL major versions. For example, `pg_partman` and `vectorscale` ship with older releases on PostgreSQL 13 to match upstream's PG13 support window.
**Extensions not available on PostgreSQL 13.** The following extensions are not available on PostgreSQL 13 because upstream never supported that major version:
- `pg_graphql`
- `pg_session_jwt`
- `anon`
All three require PostgreSQL 14 or later. If your application needs any of them, choose PostgreSQL 14+ at database creation time. Combined with [PostgreSQL 13's pending decommission](#upgrading-to-a-new-postgresql-major-version), this is one more reason to plan a migration to a newer major version.
## Full-Text Search Dictionaries
Each Miget PostgreSQL database ships with around 110 Hunspell text-search dictionaries (sourced from Debian's `hunspell-*` packages, recoded to UTF-8 in the image) and per-language stopword lists for 58 languages (sourced from [stopwords-iso](https://github.com/stopwords-iso/stopwords-iso)). Both are dropped into PostgreSQL's `tsearch_data` directory at image build time, so any locale that ships with the image is reachable from SQL with no per-database setup.
### Available locales
Highlights of what's bundled:
| Family | Locales |
|:--- |:--- |
| Polish, Czech, Slovak, Slovenian, Bosnian | `pl_pl`, `cs_cz`, `sk_sk`, `sl_si`, `bs_ba` |
| German (modern Frami), Dutch | `de_de`, `de_at`, `de_ch`, `nl_nl`, `nl_be` |
| French (comprehensive) | `fr_fr`, `fr_ca`, `fr_be`, `fr_ch`, `fr_lu` |
| English | `en_us`, `en_gb`, `en_ca`, `en_au`, `en_za` |
| Spanish (Spain + 19 Latin American regions) | `es_es`, `es_mx`, `es_ar`, `es_cl`, ... |
| Italian, Portuguese | `it_it`, `it_ch`, `pt_br`, `pt_pt` |
| Nordic | `da_dk`, `sv_se`, `sv_fi`, `nb_no`, `nn_no`, `is_is` |
| Greek, Lithuanian, Latvian | `el_gr`, `lt_lt`, `lv_lv` |
| Russian, Ukrainian, Belarusian, Bulgarian | `ru_ru`, `uk_ua`, `be_by`, `bg_bg` |
| Hebrew, Arabic (Saudi, Egyptian, plus 20 other regions) | `he_il`, `ar_sa`, `ar_eg`, ... |
| Indian languages | `hi_in`, `bn_in`, `gu_in`, `ml_in`, `te_in` |
### Registering a text-search configuration
The example below registers Polish and makes it the database's default text-search config. The same pattern works for any locale in the table above (substitute the appropriate locale slug).
```sql
CREATE TEXT SEARCH DICTIONARY public.polish_ispell (
TEMPLATE = pg_catalog.ispell,
DictFile = pl_pl,
AffFile = pl_pl,
StopWords = pl_pl
);
CREATE TEXT SEARCH CONFIGURATION public.polish (COPY = simple);
ALTER TEXT SEARCH CONFIGURATION public.polish
ALTER MAPPING FOR
asciiword, asciihword, hword_asciipart,
word, hword, hword_part
WITH public.polish_ispell, simple;
ALTER DATABASE current_database()
SET default_text_search_config = 'public.polish';
```
Verify by lemmatising an inflected word:
```sql
SELECT ts_lexize('public.polish_ispell', 'kowalskiego');
-- {kowalski}
```
Locale names in `DictFile`, `AffFile`, and `StopWords` must be all lowercase. PostgreSQL's `get_tsearch_config_filename()` rejects uppercase characters in these arguments, so use `pl_pl` (not `pl_PL`), `de_de` (not `de_DE`), and so on. The image provides both forms on disk for compatibility, but only the lowercase one is callable from SQL.
### Stopwords coverage
Per-locale `.stop` files are provided for the 58 languages covered by [stopwords-iso](https://github.com/stopwords-iso/stopwords-iso) (including Polish, German, French, Spanish, English, Italian, Portuguese, Dutch, Russian, Greek, Lithuanian, Arabic, Hebrew, Hindi, Chinese, and more).
For languages outside that set, PostgreSQL's own Snowball stop-word lists are still available under their full English names (`english`, `russian`, `french`, ...):
```sql
CREATE TEXT SEARCH DICTIONARY foo_dict (
TEMPLATE = pg_catalog.ispell,
DictFile = en_us,
AffFile = en_us,
StopWords = english -- Snowball stoplist shipped with PostgreSQL
);
```
## Further reading
Set up the free tier database and connect from anywhere over IPv4/IPv6.
Six free tiers side by side, including the catch each one hides.