Skip to main content
This quickstart installs pg_pinecone on a PostgreSQL server you manage. You create a sample table with vectors and search it with a native index, which runs the search engine Pinecone uses at scale inside Postgres. You can bring your own vectors, with no API key or network access, or have Pinecone generate embeddings. To compare native with the other engines, see Storage engines. If you already have a table with a pgvector index, complete steps 1 and 2 to install pg_pinecone, then switch from pgvector to native.

Prerequisites

  • A PostgreSQL 17 or 18 server and a superuser role on it.
  • pgvector installed on that server, because pg_pinecone uses its vector column type and distance operators. If you don’t have it, run sudo apt install postgresql-17-pgvector on Debian or Ubuntu, or brew install pgvector with Homebrew on macOS. For other Linux distributions, see the pgvector installation guide. If you install with Docker, the image includes Postgres and pgvector, so you need only Docker.
  • Optional: a Pinecone API key, if you want Pinecone to generate the embeddings. A key from the free Starter plan is enough.
The native engine never calls Pinecone. Steps 3 and 4 each have two tabs, so pick the same one in both. Your own vectors runs entirely in your database with no API key or network access, and Pinecone embeddings generates embeddings with a Pinecone-hosted model.

1. Install pg_pinecone

  1. Download the release archive for your platform and Postgres version from the releases page. Archives are published for PostgreSQL 17 and 18 on Linux x86_64, Linux arm64, and macOS arm64. The Linux x86_64 build needs a CPU that supports x86-64-v3 (Intel Haswell or newer, which covers current cloud instances), and the Linux builds need glibc 2.39 or later, such as Ubuntu 24.04 or Debian 13.
  2. Extract the archive and copy its files into your Postgres installation. The commands use PG=17. If your server runs PostgreSQL 18, change it to PG=18. To check your version, run pg_config --version. pg_config also reports where your Postgres installation keeps extension files:
On Linux arm64, use the linux-arm64 archive. If more than one Postgres version is installed, use the pg_config that belongs to the server you’re installing into. On other platforms, including Debian 12, Ubuntu 22.04, RHEL 9, and older x86_64 CPUs, build from source.

2. Connect and create the extensions

  1. Connect to your database as a superuser with psql:
    On Linux, the postgres system user is the superuser that the package creates. With Homebrew on macOS, your own user is the superuser. In the Docker image, the superuser is postgres. To connect to a different database or a remote server, add -d your_database, -h your_host, and -U your_superuser.
  2. Create the extensions. Create pgvector first, because pg_pinecone builds on its vector type and operators:
    SQL

3. Add sample data

  1. Create the table. These vectors have three dimensions:
    SQL
  2. Insert a few short documents with their vectors. In a real application, you’d generate the vectors with an embedding model of your choice. To skip that step here, each document gets a hand-made vector whose values stand for food, nature, and places:
    SQL

4. Search inside Postgres

1

Create a native index

Create a native index on the vector column. native is the default engine, so engine => 'native' is optional:
SQL
With Pinecone embeddings, pinecone.create_index() prints an informational message, labeled NOTICE, that suggests SET STORAGE PLAIN on the vector column, which speeds up searches on large tables. You can ignore it for this sample.
3

Check which index served the query

EXPLAIN shows the plan Postgres uses to run a query, including which index it reads. To confirm the native index served the search, check the plan:
SQL
The plan includes Index Scan using docs_embedding_pinecone_idx, the native index you created in step 4.1. If Postgres read every row instead, the plan would show Seq Scan.

5. Clean up

If you don’t need the sample table anymore, delete it. DROP TABLE permanently deletes the table, its rows, and its indexes, including the native index. To try switching from native to remote next, skip this step, because that guide uses the same table.
SQL

Next steps