Install pgvector for PostgreSQL
Install, enable, and verify pgvector with Docker, Ubuntu, or managed cloud PostgreSQL
pgvector is an independent extension, not a core PostgreSQL type. After installing a package or using an image that contains it, run CREATE EXTENSION vector in every target database.
Minimal Docker environment
The pgvector project publishes versioned images based on official Postgres images. This example pins PostgreSQL 18 and pgvector 0.8.2:
docker volume create pgvector18-data
docker run --name pgvector18 \
--env POSTGRES_PASSWORD=local-only-change-me \
--publish 5432:5432 \
--volume pgvector18-data:/var/lib/postgresql/data \
--detach pgvector/pgvector:0.8.2-pg18-trixie
docker exec -it pgvector18 \
psql -U postgres -d postgres -c "CREATE EXTENSION vector;"The password is for an isolated local demonstration, never production configuration. If the name or port is occupied, choose an explicit alternative; do not delete an unknown instance.
Ubuntu / Debian package
Package snapshot evidence · PkgSeek
pgvector in distribution repositories
| Distribution | Release | Indexed version | Repository | Linked advisories |
|---|---|---|---|---|
| AlmaLinux | 10 | 0.6.2-6.el10_0 | official / AppStream | — |
| AlmaLinux | 9 | 0.8.1-1.module_el9.8.0+234+5456f35d | official / AppStream | — |
| Arch Linux | rolling | 0.8.6-1 | official / extra | — |
| CentOS Stream | 10 | 0.6.2-8.el10 | official / AppStream | — |
| CentOS Stream | 9 | 0.8.1-1.module_el9+1300+1c4aa8df | official / AppStream | — |
| Fedora | 42 | 0.6.2-4.fc42 | official / everything | — |
| Fedora | 43 | 0.8.0-1.fc43 | official / everything | — |
| Fedora | 44 | 0.8.0-2.fc44 | official / everything | — |
| Oracle Linux | 10 | 0.6.2-6.el10_0 | official / appstream | — |
| Oracle Linux | 9 | 0.6.2-2.module+el9.8.0+90925+e22a792e | official / appstream | — |
| Red Hat Enterprise Linux | 10.2 | 0.6.2-6.el10_0 | official / AppStream | — |
| Red Hat Enterprise Linux | 9.8 | 0.6.2-2.module+el9.8.0+24096+5a959ed6 | official / AppStream | — |
| Rocky Linux | 10 | 0.6.2-6.el10_0 | official / AppStream | — |
| Rocky Linux | 9 | 0.6.2-2.module+el9.8.0+40212+d6f50005 | official / AppStream | — |
The same extension may be named pgvector, postgresql18-pgvector, or another server-major-specific package across distributions. This table only shows exact pgvector coordinates; it does not establish whether every versioned package exists.
Package snapshot evidence · PkgSeek
PGDG: postgresql-18-pgvector
PkgSeek did not return an exact match for this coordinate. This means “not present in this snapshot”, not “the package does not exist”. Confirm with the upstream repository before acting.
If no exact coordinate appears above, verify the target PGDG repository metadata. Do not infer an Ubuntu or Debian versioned package name from a generic pgvector record.
After configuring the official PostgreSQL Apt repository, the extension package is bound to the server major:
sudo apt install postgresql-18-pgvector
sudo -u postgres psql -d app -c "CREATE EXTENSION vector;"Installing at OS level does not enable every database. Verify the actual version:
SELECT extname, extversion
FROM pg_extension
WHERE extname = 'vector';Before upgrading, read release notes and test this in the target database:
ALTER EXTENSION vector UPDATE;Minimal query verification
CREATE TABLE vector_demo (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
embedding vector(3) NOT NULL
);
INSERT INTO vector_demo (embedding)
VALUES ('[1,2,3]'), ('[4,5,6]'), ('[1,1,1]');
SELECT id, embedding <-> '[1,2,2]'::vector AS l2_distance
FROM vector_demo
ORDER BY embedding <-> '[1,2,2]'::vector
LIMIT 2;Without an approximate index, this is exact search. When scale and real filters justify it, evaluate HNSW or IVFFlat using the pgvector production guide.
Managed cloud PostgreSQL
Managed services commonly restrict host access and extension allowlists. Confirm:
- engine major and the exact
vectorextension version; - who can run
CREATE EXTENSIONandALTER EXTENSION; - whether that version supports HNSW, IVFFlat, and iterative scans;
- whether extensions follow engine upgrades or require manual maintenance;
- disk, memory, WAL, and replica-lag limits during index builds.
Do not mix different embeddings
When model, dimension, normalization, or distance semantics change, rebuild into a new column or table and evaluate it. Equal dimensions do not make vectors semantically comparable.
Use the pgvector installation documentation for current releases and methods.
Last updated on