> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Supported Postgres Extensions

> Fly.io Managed Postgres runs Postgres 16, 17, and 18. Enable extensions per database, including pgvector and PostGIS, and check which ones your cluster offers.

![Illustration by Annie Ruygt of a balloon doing a lot of tasks](https://mintcdn.com/fly-io/v-XOGeVK6s4rQ-4y/images/Managed_Postgres.png?fit=max\&auto=format\&n=v-XOGeVK6s4rQ-4y\&q=85\&s=8bc520d714c11065db621817396c13d6)

## Overview

Fly.io Managed Postgres (MPG) supports Postgres 16, 17, and 18. Clusters include extensions for the Postgres version they run, including commonly used tools and utilities like `pgcrypto`, `pg_stat_monitor`, and `citext`. The Postgres Extensions page lets you enable or disable Postgres extensions for your managed database cluster. Extensions add features to your database, such as new data types and functions.

MPG has v1 and v2 clusters. In the dashboard, v2 clusters have a **v2** badge next to the cluster name. Postgres 18 is available on v2 clusters only.

By default the `plpgsql`, `pg_stat_monitor`, and `pgaudit` extensions are enabled and cannot be disabled.

## Using the Extensions Page

### Search for Extensions

* Use the search bar to quickly find extensions by name or description

### Select a Database

* Use the dropdown on the right to choose which database to manage
* Extensions are enabled/disabled per database, not cluster-wide

### Enable or Disable Extensions

* Click the toggle switch next to any extension to enable or disable it
* Each extension displays its version number (e.g., v1.3) showing which version is installed when enabled, or which version will be installed when you enable it

### Additional notes

* If your cluster is still initializing or otherwise degraded, you'll need to wait before managing extensions

## Supported third-party extensions

Aside from the extensions bundled with the default Postgres distribution, MPG clusters include these third-party extensions:

* [pgvector](https://github.com/pgvector/pgvector) (`vector`), which you can enable from the Extensions page for your cluster.
* [PostGIS](https://postgis.net) (`postgis` and its companion extensions), on clusters with PostGIS support.
* [pg\_repack](#pg_repack), on v2 clusters, for rebuilding bloated tables while your app keeps reading and writing.
* [pg\_stat\_monitor](https://docs.percona.com/pg-stat-monitor/) and [pgaudit](https://github.com/pgaudit/pgaudit), which are always enabled.

To get PostGIS support, turn it on when you create the cluster:

* Via the dashboard, check "Enable PostGIS" under the "Extensions" section
* When creating a cluster via flyctl, pass the `--enable-postgis-support` flag:

```bash theme={null}
flyctl mpg create --enable-postgis-support
```

On a v2 cluster, you can also add PostGIS support later. Click **Enable PostGIS support** on the Extensions page. The cluster does a rolling restart, and existing connections might break while the replicas restart. After the restart finishes, enable `postgis` in each database that needs it.

We plan on supporting additional third-party extensions based on user feedback. If there's an extension you rely on or commonly use, please let us know!

### How extensions are updated

We rebuild v2 cluster images every week with the latest releases of the extensions we ship, including security fixes. A new image reaches your cluster during its [maintenance window](https://docs.fly.io/postgres/maintenance-windows.md). PostGIS and pg\_repack are pinned and change only when we update them. v1 clusters don't get these updates.

## Supported extensions

This table lists the extensions you can enable on v1 clusters, v2 clusters, or both. Check your cluster's Extensions page for the extensions and versions available to it.

| Name | v1 clusters | v2 clusters | Description |
| - | - | - | - |
| `address_standardizer` | | ✓¹ | Parses an address into its constituent elements. Part of PostGIS. |
| `address_standardizer_data_us` | | ✓¹ | US rules and lookup data for `address_standardizer`. Part of PostGIS. |
| `autoinc` | | ✓ | Provides a trigger function that stores the next value of a sequence into an integer field. |
| `bloom` | | ✓ | Provides an index access method based on Bloom filters. A Bloom filter is a space-efficient data structure that is used to test whether an element is a member of a set. |
| `btree_gin` | ✓ | ✓ | Provides GIN index operator classes with B-tree-like behavior. This allows you to use GIN indexes, which are typically used for full-text search, in situations where you might otherwise use a B-tree index, such as with integer or text data. |
| `btree_gist` | ✓ | ✓ | Provides GiST (Generalized Search Tree) index operator classes that implement B-tree-like behavior. This allows you to use GiST indexes, which are typically used for multidimensional and non-scalar data, in situations where you might otherwise use a B-tree index, such as with integer or text data. |
| `citext` | ✓ | ✓ | Provides a case-insensitive character string type, citext. Essentially, it internally calls lower when comparing values. Otherwise, it behaves almost exactly like text. |
| `cube` | ✓ | ✓ | Implements a data type cube for representing multidimensional cubes. |
| `dblink` | | ✓ | Provides functions to connect to other PostgreSQL databases from within a database session. This allows for queries to be run across multiple databases as if they were on the same server. |
| `dict_int` | ✓ | ✓ | An example of an add-on dictionary template for full-text search. It's used to demonstrate how to create custom dictionaries in PostgreSQL. |
| `dict_xsyn` | | ✓ | Example synonym full-text search dictionary. This dictionary type replaces words with groups of their synonyms, and so makes it possible to search for a word using any of its synonyms. |
| `earthdistance` | | ✓ | This module provides two different approaches to calculating great circle distances on the surface of the Earth. The first one depends on the cube module. The second one is based on the built-in point data type, using longitude and latitude for the coordinates. |
| `fuzzystrmatch` | ✓ | ✓ | Determines similarities and distance between strings. |
| `hstore` | ✓ | ✓ | Implements the hstore data type for storing sets of key/value pairs within a single PostgreSQL value. |
| `insert_username` | | ✓ | Provides a trigger function that stores the current user's name into a text field. |
| `intagg` | | ✓ | Integer aggregator and enumerator. |
| `intarray` | ✓ | ✓ | Provides a number of useful functions and operators for manipulating null-free arrays of integers. |
| `isn` | ✓ | ✓ | Provides data types for the following international product numbering standards: EAN13, UPC, ISBN (books), ISMN (music), and ISSN (serials). |
| `lo` | ✓ | ✓ | Provides support for managing Large Objects (also called LOs or BLOBs). This includes a data type lo and a trigger lo\_manage. |
| `ltree` | ✓ | ✓ | Implements a data type ltree for representing labels of data stored in a hierarchical tree-like structure. Extensive facilities for searching through label trees are provided. |
| `moddatetime` | | ✓ | Provides a trigger function that stores the current time into a timestamp field. |
| `old_snapshot` | | ✓ (Postgres 16 only) | Allows inspection of the server state that is used to implement old\_snapshot\_threshold. |
| `pg_prewarm` | | ✓ | Provides a convenient way to load relation data into either the operating system buffer cache or the PostgreSQL buffer cache. This can be useful for reducing the time needed for a newly started database to reach its full performance potential by preloading frequently accessed data. |
| `pg_repack` | | ✓ | Rebuilds tables and indexes online to remove bloat. See [Rebuild bloated tables with pg\_repack](#pg_repack). |
| `pg_stat_monitor` | ✓ | ✓ | A more advanced version of pg\_stat\_statements for tracking planning and execution statistics of all SQL statements executed by a server. Includes all columns available in pg\_stat\_statements, plus additional ones. Always enabled. |
| `pg_stat_statements` | | ✓ | A module for tracking planning and execution statistics of all SQL statements executed by a server. Consider pg\_stat\_monitor instead, which is always enabled. |
| `pg_trgm` | ✓ | ✓ | Provides functions and operators for determining the similarity of alphanumeric text based on trigram matching. A trigram is a contiguous sequence of three characters. The extension can be used for text search and pattern matching operations. |
| `pgaudit` | ✓ | ✓ | Provides detailed session and object audit logging. Always enabled. |
| `pgcrypto` | ✓ | ✓ | Provides cryptographic functions for PostgreSQL. |
| `pgrowlocks` | | ✓ | Provides a function to show row locking information for a specified table. |
| `plpgsql` | ✓ | ✓ | PL/pgSQL procedural language. Always enabled. |
| `postgis` | ✓¹ | ✓¹ | Geographic information system extension for Postgres. |
| `postgis_raster` | ✓¹ | ✓¹ | Raster data support for PostGIS. |
| `postgis_sfcgal` | ✓¹ | ✓¹ | SFCGAL support for PostGIS. |
| `postgis_tiger_geocoder` | | ✓¹ | Geocoder and reverse geocoder for US Census TIGER data. Part of PostGIS. |
| `postgis_topology` | ✓¹ | ✓¹ | Topology data support for PostGIS. |
| `refint` | | ✓ | Provides trigger functions for implementing referential integrity. |
| `seg` | ✓ | ✓ | Implements a data type seg for representing line segments, or floating point intervals. seg can represent uncertainty in the interval endpoints, making it especially useful for representing laboratory measurements. |
| `sslinfo` | | ✓ | Provides information about the SSL certificate that the current client provided when connecting to PostgreSQL. |
| `tablefunc` | ✓ | ✓ | Includes various functions that return tables (that is, multiple rows). These functions are useful both in their own right and as examples of how to write C functions that return multiple rows. |
| `tcn` | ✓ | ✓ | Provides a trigger function that notifies listeners of changes to any table on which it is attached. |
| `tsm_system_rows` | ✓ | ✓ | Provides the table sampling method SYSTEM\_ROWS, which can be used in the TABLESAMPLE clause of a SELECT command. |
| `tsm_system_time` | ✓ | ✓ | Provides the table sampling method SYSTEM\_TIME, which can be used in the TABLESAMPLE clause of a SELECT command. |
| `unaccent` | ✓ | ✓ | A text search dictionary that removes accents (diacritic signs) from lexemes. It's a filtering dictionary, which means its output is always passed to the next dictionary (if any). This allows accent-insensitive processing for full text search. |
| `uuid-ossp` | ✓ | ✓ | Provides functions to generate universally unique identifiers (UUIDs) using one of several standard algorithms. |
| `vector` | ✓ | ✓ | Provides a vector data type and the ivfflat and hnsw access methods. |
| `xml2` | | ✓ | Provides XPath querying and XSLT processing. |

¹ Only on clusters with PostGIS support. See [Supported third-party extensions](#supported-third-party-extensions).

## Rebuild bloated tables with pg\_repack

[pg\_repack](https://reorg.github.io/pg_repack/) rebuilds a table and its indexes to give back the space that dead rows take up, while your app keeps reading and writing to the table. `VACUUM FULL` does the same job, but it holds an `ACCESS EXCLUSIVE` lock on the table for the whole run, which blocks every read and write. pg\_repack only takes that lock briefly, at the start and at the end of the run. In between, it holds a `SHARE UPDATE EXCLUSIVE` lock: inserts, updates, and deletes carry on as usual. `VACUUM`, `ANALYZE`, `CREATE INDEX` (including `CONCURRENTLY`), and `ALTER TABLE` on that table wait until it finishes, and autovacuum skips the table.

pg\_repack is available on v2 clusters. We ship pg\_repack 1.5.3 with a security fix from upstream that isn't in a pg\_repack release yet.

> [!NOTE]
>
> pg\_repack rolls out to v2 clusters starting November 15, 2026. Until it reaches your cluster, it doesn't appear on your cluster's Extensions page and you can't enable it.

### Enable pg\_repack

Enable pg\_repack in each database whose tables you want to repack, either with the toggle on your cluster's Extensions page or with [`fly mpg databases extensions enable`](https://docs.fly.io/flyctl/cmd/fly_mpg_databases_extensions_enable):

```bash theme={null}
fly mpg databases extensions enable pg_repack --cluster <cluster-id> --database <database>
```

pg\_repack doesn't accept `--schema`. It always creates its own `repack` schema. `fly mpg databases extensions list` shows `public` as pg\_repack's schema anyway, and you can ignore it.

### Install the pg\_repack client

You run pg\_repack from your own machine, and the client must be version **1.5.3** exactly. It refuses to work with any other version of the extension. Install it from the [PostgreSQL apt repository (PGDG)](https://wiki.postgresql.org/wiki/Apt) on Debian or Ubuntu, and hold it at 1.5.3 so `apt upgrade` doesn't move it. Use the package for your cluster's Postgres major version; this example is for Postgres 17:

```bash theme={null}
# Add the PGDG repository.
sudo apt update
sudo apt install -y postgresql-common ca-certificates
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y

# PGDG drops old versions when it publishes new ones. Its archive keeps them.
. /etc/os-release
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt-archive.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg-archive main" \
  | sudo tee /etc/apt/sources.list.d/pgdg-archive.list

# The package depends on the Postgres server package. Don't let it create
# a local database cluster you won't use.
sudo mkdir -p /etc/postgresql-common/createcluster.d
echo 'create_main_cluster = false' \
  | sudo tee /etc/postgresql-common/createcluster.d/no-main-cluster.conf

sudo apt update
sudo apt install -y 'postgresql-17-repack=1.5.3-*'
sudo apt-mark hold postgresql-17-repack

pg_repack --version
```

The last command should print `pg_repack 1.5.3`.

#### On macOS, Windows, or other Linux distributions

Run the same steps in a Debian container, and connect to your cluster through `fly mpg proxy` running on your machine. In one terminal, start the proxy:

```bash theme={null}
fly mpg proxy <cluster-id>
```

In another terminal, start the container. Inside a container, `localhost` is the container itself, and `fly mpg proxy` only listens on your machine's `localhost`. How you start the container, and how it reaches the proxy, depends on where it runs:

* **macOS or Windows.** Start the container as usual and reach the proxy at `host.docker.internal`, which Docker Desktop forwards to your machine's `localhost`: for example `postgres://<user>:<password>@host.docker.internal:16380/<database>`. With Podman, use `host.containers.internal`.

  ```bash theme={null}
  docker run --rm -it debian:trixie bash
  ```

* **Linux.** Start the container with `--network host`, so it shares your machine's network, and connect to `localhost:16380` as you would outside the container. `host.docker.internal` doesn't reach the proxy on Linux, even with `--add-host host.docker.internal:host-gateway`, because the proxy doesn't listen on that address.

  ```bash theme={null}
  docker run --rm -it --network host debian:trixie bash
  ```

In the container, run the commands above, leaving out `sudo` (you're root in the container).

### Before you repack

* **Primary key.** The table needs a primary key, or a unique index on `NOT NULL` columns.
* **Free disk space.** pg\_repack builds a full copy of the table and its indexes before it drops the old one. Upstream recommends free space of about twice the size of the tables and indexes you're repacking. If the table, its indexes, and the copy wouldn't fit under the [1 TB storage limit](https://docs.fly.io/postgres#database-storage), don't repack it.
* **Storage billing.** On v2 clusters the volume grows automatically as it fills, so a large repack can grow it. A volume doesn't shrink afterward, but v2 clusters are [billed](https://docs.fly.io/postgres#pricing) for the storage your databases use, not for the volume's size. Usage goes up while pg\_repack runs and falls once it drops the old copy, usually below where it started.
* **WAL and replicas.** Rewriting a table generates write-ahead log (WAL) in proportion to its size, so your replicas can lag behind the primary while pg\_repack runs.
* **Conflicting queries.** pg\_repack needs a brief exclusive lock on the table at the start of the run and at the final swap. Long-running queries and sessions left idle in a transaction on the table hold it up. Before the swap, pg\_repack also waits, with no timeout, for every transaction that started before it did, so a session left idle in a transaction anywhere in that database stalls it. Check for both before you start. See [If pg\_repack can't get its lock](#if-pg_repack-cant-get-its-lock) for what happens when it's blocked.

### Run pg\_repack

Only a table's owner can repack it. The tables you create belong to the `schema_admin` role, so connect as a user with the [Schema Admin role](https://docs.fly.io/postgres/cluster-configuration.md#schema-admin), such as `fly-user`. Writer and Reader users can't repack tables. Because you aren't a superuser, pass `-k` (`--no-superuser-check`).

Use your cluster's **direct** connection string, not the pooled one. In Transaction mode, PgBouncer can move you to a different server connection between transactions, which breaks pg\_repack. A direct connection also makes pg\_repack's sessions ordinary Postgres sessions that you can find and end if a run gets stuck. See [Create and connect](https://docs.fly.io/postgres/create-and-connect.md#manually-connect-an-application-using-a-connection-string) for where to find the direct connection string, and [Setting up a Proxy Connection](https://docs.fly.io/postgres/create-and-connect.md#setting-up-a-proxy-connection) to reach it from your machine with `fly mpg proxy`.

The database in the connection string must be the one where you enabled pg\_repack. The direct connection string points at `fly-db`, so change the database name at the end if your tables are in another database. Through `fly mpg proxy`, the connection string looks like `postgres://<user>:<password>@localhost:16380/<database>`.

```bash theme={null}
pg_repack -k -D -d "<direct connection string>" -t public.<table>
```

`-D` (`--no-kill-backend`) stops pg\_repack from trying to cancel other sessions, which your user can't do anyway. See [If pg\_repack can't get its lock](#if-pg_repack-cant-get-its-lock). Pass `-t` once for each table you want to repack. See the [pg\_repack documentation](https://reorg.github.io/pg_repack/) for its other options.

A successful run prints one line per table and exits with status 0:

```output theme={null}
INFO: repacking table "public.<table>"
```

### If pg\_repack can't get its lock

pg\_repack waits up to `--wait-timeout` seconds (60 by default) for each of its exclusive locks. When the wait runs out, it normally cancels the queries in its way, but your user can't cancel other sessions, including its own. What happens next depends on `-D` (`--no-kill-backend`):

* **With `-D`.** pg\_repack gives up on the table, leaves it as it was and normally cleans up after itself. It still exits with status 0, so check its output for these lines:

  ```output theme={null}
  WARNING: timed out, do not cancel conflicting backends
  INFO: Skipping repack public.<table> due to timeout
  ```

  If the lock is still blocked during cleanup, pg\_repack exits with an error and leaves an [interrupted run](#if-a-run-is-interrupted) behind.

* **Without `-D`.** The run fails with an error, which can leave an [interrupted run](#if-a-run-is-interrupted) behind.

Once the conflicting queries and sessions are gone, run pg\_repack again. To wait longer, raise `--wait-timeout`.

### If a run is interrupted

If pg\_repack stops partway, because the client was killed, its connection dropped, or the cluster failed over, it leaves a trigger on the table and its log and work tables in the `repack` schema. Your table keeps working, but every write to it also goes to the log table, which keeps growing until you clean up.

To clean up:

1. If pg\_repack's session is still open on the server, end it. Connect as the same user that ran pg\_repack, for example with `fly mpg connect --username <user>`, and run:

   ```sql theme={null}
   SET ROLE NONE;
   SELECT pg_terminate_backend(pid) FROM pg_stat_activity
     WHERE application_name = 'pg_repack' AND usename = session_user;
   SET ROLE schema_admin;
   ```

   pg\_repack names its sessions `pg_repack` (`application_name`), which is how this query finds them, so don't override `application_name` in the connection string or with `PGAPPNAME` when you run pg\_repack. Your user acts as `schema_admin` by default, which can't end your user's own sessions. `SET ROLE NONE` switches back to your user for the `pg_terminate_backend` call. `RESET ROLE` doesn't help here: it returns to the default, `schema_admin`.

2. Disable pg\_repack with `--force`, using [`fly mpg databases extensions disable`](https://docs.fly.io/flyctl/cmd/fly_mpg_databases_extensions_disable):

   ```bash theme={null}
   fly mpg databases extensions disable pg_repack --cluster <cluster-id> --database <database> --force
   ```

   `--force` drops the extension along with everything that depends on it, which removes the leftover trigger and tables. Your table and its data stay as they are. The toggle on the Extensions page disables extensions without `--force`, so it fails while the leftovers are there.

   > [!WARNING]
   >
   > `--force` also removes the trigger and tables of any other pg\_repack run in progress in that database, which breaks that run. Make sure no other run is in progress.

3. Enable pg\_repack again:

   ```bash theme={null}
   fly mpg databases extensions enable pg_repack --cluster <cluster-id> --database <database>
   ```

You can now repack the table again.
