We strongly recommend
0.27.0 or later for substantial vector search
improvements.mock_items table from Configure Your Environment, which has an eight-dimensional embedding column. For the mental model, see How Vector Search Works.
1. Store Vectors
Vectors are stored in apdb.vector(N) column, where N is the number of dimensions. mock_items already has one, declared as pdb.vector(8).
On your own table, declare the column with the dimension of your embedding model. The dimension is required to index the column:
'[0.1, 0.2, 0.3]'. Pass it from your application as a parameter:
pdb.vector requires 0.27.2 or later. To use an existing pgvector column
instead, see Compatibility with pgvector
Types.2. Create the Index
Add the vector column to a ParadeDB index together with every column you will filter or sort on. The operator class after the column sets the distance metric:If you created
search_idx in Create Your First
Index, skip this step. That index already
includes embedding, and a table can have only one ParadeDB index.
Pick the metric your embedding model was trained for. For a large table, load the data first, then create the index.
3. Query
A vector search is anORDER BY on the distance with a LIMIT. To use the ParadeDB index it also needs a ParadeDB search operator in the WHERE clause. With no filter, use pdb.all().
In an application, the query vector comes from your embedding model and is passed in as a parameter. This guide uses the embedding stored for one row, Sleek running shoes, as the query vector. Read it first:
Expected Response
mock_items stores 8-dimension vectors, so the value is short enough to paste. Order the rows by their distance to it:
Expected Response
0. mock_items holds small sample embeddings, so the other neighbors are not related by meaning.
To search within a subset, filter on indexed columns. The result is the nearest rows among those that match:
Expected Response
4. Verify
EXPLAIN shows whether the index is doing the work. Look for TopKScanExecState:
Expected Response
Sort node above the scan means the query did not use the vector index. See Troubleshooting.
5. Tune
Vector search over a large index is approximate. One setting trades accuracy for speed:100. Before going to production, measure recall on a sample of real queries and choose the lowest value that meets your target. Small tables are searched exactly and need no tuning.
Next Steps
Indexing Vectors
Add
pdb.vector or pgvector vector columns to a ParadeDB index.Querying Vectors
Run nearest-neighbor queries with filters, joins, and deterministic
ordering.
Tuning Recall and Latency
Trade recall against latency and read
EXPLAIN ANALYZE for a vector query.Vector Indexes
Build large vector indexes and keep them fast under writes.
Troubleshooting
Diagnose slow queries, low recall, warnings, and errors.
Hybrid Search
Combine vector and full-text rankings.