Skip to main content
A table with a pgvector index, such as an HNSW index, is on the pgvector engine. You can switch it to native, which runs the search engine Pinecone uses at scale inside Postgres. Your queries and data stay the same, and you can switch back to pgvector at any time.

Before you begin

  • pg_pinecone installed and created in the database, as steps 1 and 2 of the quickstart show.
  • A table with a vector column and a pgvector index on that column created with CREATE INDEX. If pinecone.create_index() built the pgvector index instead, skip this guide and switch it with one call: SELECT pinecone.set_engine('your_table', 'native');.
  • A single-column primary key, if you plan to switch to remote later. A native index doesn’t need one.

Replace the index

1

Create a native index

Create a native index on the table’s vector column. The pgvector index keeps serving queries while the native index builds:
SQL
pinecone.create_index() uses cosine distance by default. If your pgvector index uses a different distance, pass the matching metric: 'l2' for vector_l2_ops, or 'ip' for vector_ip_ops.If your queries filter on one column, such as a tenant ID, add it as a filter column with filter_column => 'tenant_id'. See Filter column.
2

Drop the pgvector index

SQL
Your queries now use the native index.
3

Check which index serves queries

Run EXPLAIN on a similarity query. This one uses a row’s own vector as the query:
SQL
The plan includes Index Scan using your_table_embedding_pinecone_idx. pinecone.create_index() names the index <table>_<column>_pinecone_idx. On a small table, Postgres may choose to read every row instead of using any index, because that’s cheaper.

Switch back to pgvector

If the table uses the remote engine, switch it back to native first.
1

Drop the native index

SQL
Until the pgvector index exists, queries on the table read every row.
2

Create the pgvector index

SQL
Postgres builds the index from the vectors already in the table.