Postgres extensions
Every Naijacloud Postgres database can use pgvector for embeddings, PostGIS for maps and distances, pg_cron for scheduled SQL, and the PostgreSQL contrib extensions. Turn one on with CREATE EXTENSION.
Supported extensions
| Extension | Version | What it is for |
|---|---|---|
vector (pgvector) | 0.8.7 | Embeddings and similarity search, with HNSW and IVFFlat indexes |
postgis | 3.6.4 | Geometry and geography types, spatial indexes and functions |
postgis_raster, postgis_topology, postgis_sfcgal | 3.6.4 | The rest of PostGIS |
pg_cron | 1.6.8 | Run SQL on a schedule, inside the database |
pg_trgm | 1.6 | Fuzzy text search and LIKE '%…%' indexes |
pgcrypto, uuid-ossp | Hashing, encryption and UUIDs | |
citext, hstore, unaccent, fuzzystrmatch, ltree, btree_gin, btree_gist, pg_stat_statements and the rest of contrib | 18 | Shipped with PostgreSQL 18 |
They are available on every size, Free included. pg_net and
Supabase's own extensions (pgsodium, supabase_vault, pg_graphql,
pgjwt) are not: make HTTP calls from your app or a cron
job instead.
To see the full list your database offers, run this in Studio:
select name, default_version from pg_available_extensions order by name;Turning one on
Nothing is installed until you ask for it. The database user Naijacloud created
can install extensions, so run CREATE EXTENSION from Studio, psql, or your
migrations:
create extension if not exists vector;
create extension if not exists postgis;
create extension if not exists pg_cron;Prisma, Drizzle and most migration tools can do the same from a migration, so a fresh database gets the extension on its first deploy.
pgvector
create table documents (
id bigserial primary key,
content text,
embedding vector(1536)
);
create index on documents using hnsw (embedding vector_cosine_ops);
select id, content
from documents
order by embedding <=> $1
limit 5;vector columns hold up to 2,000 dimensions with an index (halfvec up to
4,000). An HNSW index is held in memory while it is used, so size the database
for it: a million 1,536-dimension vectors need several GB. Start on Free to
build, and move up a size when the index outgrows it.
pg_cron
pg_cron runs in your database, the one created with the service. Schedules are
in UTC:
select cron.schedule('nightly-cleanup', '0 2 * * *',
$$delete from sessions where expires_at < now()$$);
select * from cron.job;
select * from cron.job_run_details order by start_time desc limit 10;
select cron.unschedule('nightly-cleanup');A job runs as the user who scheduled it. Use pg_cron for work that is only SQL; for anything that calls an API or runs your code, use a cron job.
Databases created before extensions were available
A database created before Naijacloud added these extensions gets them the next time it restarts onto the new server, which happens when you:
- change its size (any change of instance type), or
- pause and resume it: Pause database, then Resume database, on its Settings tab.
Either one keeps your data, connection string and password. The database is
unavailable for a few seconds while it restarts, as after any restart. Until
then, create extension vector answers
extension "vector" is not available. Backups and point-in-time recovery carry
on as before.
Related: Connecting to a database and Backups & restore.