Installing pgvector

Prerequisites

Before you begin the installation process:

  1. Install your flavor of Postgres if not already installed. See:

  2. Set up the repository:

    Setting up the repository is a one-time task. If you've already set up your repository, you don't need to perform this step.

    To set up the repository, go to EDB repositories and follow the instructions provided there.

Hardware considerations for vector workloads

pgvector stores and operates on floating-point vectors in memory during index builds and queries. For production vector workloads:

  • Memory: HNSW index builds are memory-intensive. Set maintenance_work_mem to at least 1 GB before building indexes on large datasets (for example, SET maintenance_work_mem = '4GB'). Ensure shared_buffers is sized appropriately for your workload. To halve memory usage, consider using the halfvec type instead of vector — half-precision vectors store each dimension in 2 bytes instead of 4 and are supported by both HNSW and IVFFlat indexes. See the pgvector documentation for details.

  • Storage: Vector columns consume significant disk space. A single 1536-dimension vector column (as used by OpenAI embeddings) requires approximately 6 KB per row, so a table with 1 million rows requires roughly 6 GB for the vector column alone.

  • CPU: Both HNSW and IVFFlat index scans are CPU-bound. CPUs with AVX-512 or AVX2 support benefit from hardware-accelerated distance calculations.

Installing the package

  • <postgres> is the distribution of Postgres you're using:

    Postgres distributionValue
    PostgreSQLpg
    EDB Postgres Advanced Serveras
    EDB Postgres Extended Serverpostgresextended
  • <postgres_version> is the version of Postgres you're using.

For example, to install pgvector for EDB Postgres Advanced Server 16 on a RHEL 9 platform:

sudo dnf -y install edb-as16-pgvector0

After installing, see Configuring pgvector to enable the extension in your database.


Could this page be better? Report a problem or suggest an addition!