> ## Documentation Index
> Fetch the complete documentation index at: https://www.paradedb.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting Vector Search

> Diagnose slow queries and low recall, and look up vector warnings and errors

Use this page when a vector query is slow, returns unexpected rows, or raises a warning or an error. Most answers start with the query's `EXPLAIN` plan.

## A Query Does Not Use the Vector Index

A query that uses the vector index has `Exec Method: TopKScanExecState` in its `EXPLAIN` plan and no `Sort` node. When it does not, find the cause here.

| What you see | Cause | Fix |
| - | - | - |
| No `Custom Scan`, no warning. | The `WHERE` clause has no ParadeDB search operator. | Add `id @@@ pdb.all()`, or write a filter with a ParadeDB operator such as `===`. |
| `Custom Scan` under a `Sort`, no warning. | The query has no `LIMIT`. | Add a `LIMIT`. |
| `ORDER BY uses the <=> (Cosine) operator but the index attribute was built with the vector_l2_ops opclass (L2)` | The distance operator does not match the index's metric. | Use the operator for the index's metric, or drop the index and create it with the operator class you want. |
| `ORDER BY columns cannot be pushed down to the index` | The query vector is a subquery or a joined column, or the distance is taken on an expression instead of the indexed column. | Pass the query vector as a literal or parameter. See [The Query Vector](https://www.paradedb.com/docs/reference/vector/querying.md#the-query-vector). |
| `only partial prefix of ORDER BY can be pushed down` | A tiebreaker column is not in the index or is not sortable. | Add the column to the index. Text tiebreakers need the [literal tokenizer](https://www.paradedb.com/docs/reference/tokenizers/available-tokenizers/literal.md). |
| `ORDER BY has 6 columns but Top K supports maximum 5` | Too many `ORDER BY` keys. | Use the distance plus at most four tiebreakers. |
| `JoinScan not used: ...` | A join ordered by vector distance could not be pushed down. | The warning states the reason. |

The warnings arrive inside a longer message that starts with `Query has LIMIT N but is not using Top K scan`.

To make these warnings fail a query in development and CI:

```sql theme={null}
SET paradedb.planner_warnings = 'error';
```

The first two rows of the table raise no warning under any setting, so check new queries with `EXPLAIN`.

## A Query Is Slow

Run the query with `EXPLAIN ANALYZE` and read the [`Vector Search` group](https://www.paradedb.com/docs/reference/vector/tuning#reading-explain-analyze).

| What you see | Meaning | Fix |
| - | - | - |
| No `TopKScanExecState`. | Postgres is sorting the rows. | See the table above. |
| A large `flat` count on `Rows Scored`, or many `flat` segments. | Recent writes have not been merged into clustered segments. | Confirm [background merging](https://www.paradedb.com/docs/operate/performance-tuning/writes.md#ensuring-merging-happens-in-the-background) is enabled. The probe setting does not help. |
| `heap_filter` in the `Tantivy Query` line. | A filter column is not in the index. | Add the column to the index. |
| `Clusters: probed` close to `total`. | The query reads most of the index. | Lower `paradedb.vector_cluster_max_probe` if recall allows. |
| The plan is fast but the statement is not. | Postgres reads each returned row from the table. | Lower the `LIMIT` or `OFFSET`, or select fewer wide columns. |

## Recall Is Low

First [measure recall](https://www.paradedb.com/docs/reference/vector/tuning.md#measuring-recall) with the same filter and `LIMIT` the application uses.

| Check | What to do |
| - | - |
| `Stop: budget=` is above `0` in `EXPLAIN ANALYZE`. | Raise `paradedb.vector_cluster_max_probe`. |
| The query has a filter. | Filtered queries get a smaller budget. Raise `paradedb.vector_cluster_max_probe` for them. |
| `Stop: recall=` is above `0` and `budget=0`. | Adaptive probing ended the search, so raising the probe setting has no effect. Compare recall with `paradedb.vector_adaptive_probing = off`. |
| The index metric differs from the one the embedding model uses. | Create the index with the right operator class. |
| The index was built with non-default [options](https://www.paradedb.com/docs/reference/indexing/field-types/vector.md#index-options). | Rebuild with the defaults and compare. |

## Fewer Rows Than the LIMIT

A query ordered by distance can return fewer rows than its `LIMIT` for these reasons:

* Rows with a `NULL` vector are never returned by a query ordered by distance.
* The filter matches fewer rows than the `LIMIT`.
* A filter in an outer query removed rows after the nearest neighbors were chosen.

## Descending Order Returns the Nearest Rows

`ORDER BY embedding <=> '...' DESC` with a search operator returns the nearest rows, in ascending order of distance. Farthest-first ordering is not supported by the vector index. To get it, remove the search operator so that Postgres sorts the rows.

## Errors

| Message | Fix |
| - | - |
| `vector field 'embedding' must declare dimensions using pdb.vector(N) or vector(N)` | Declare the column's dimension, as in `pdb.vector(1536)`. |
| `a ParadeDB index may only index one vector field` | Keep one vector column in the index. |
| `a relation may only have one ParadeDB index` | Add the vector column to the table's existing ParadeDB index. |
| `operator class "halfvec_l2_ops" does not exist for access method "paradedb"` | `halfvec`, `sparsevec`, and `bit` columns cannot be indexed. Use `pdb.vector` or pgvector's `vector`. |
| `invalid postgres oid passed to search index schema: Custom(...)` | The column has a type that cannot be indexed, such as `halfvec` with no operator class. Use `pdb.vector` or pgvector's `vector`. |
| `quantization requires dimension ≥ 64` | Remove the `quantization` option for vectors under 64 dimensions. |
| `expected 3 dimensions, not 8` | The value's dimension differs from the column's. |
| `query vector length 3 does not match field "embedding" dim 8` | The query vector's dimension differs from the column's. |
| `vector ORDER BY parameter $1 is NULL` | The query vector parameter is `NULL`. Pass a vector. |
| `not implemented: Vector distance ORDER BY can only be the primary sort key` | Put the distance first in `ORDER BY`. |
| `` `maintenance_work_mem` is not high enough to give each parallel worker 15MB `` | Raise `maintenance_work_mem` or lower `max_parallel_maintenance_workers`. See [Memory](https://www.paradedb.com/docs/operate/performance-tuning/vector-indexes.md#memory). |
| `insufficient disk space to complete the index build` | The build estimated that the rest of the index does not fit. Free or add disk space. |
| `index "x" has an unsupported vector storage format` | The index was written by a release with a different vector storage format. Run `REINDEX`. |
| `pdb.score() cannot tie-break a vector distance ORDER BY` | Use an indexed column as the tiebreaker, or combine the rankings with [RRF](https://www.paradedb.com/docs/reference/hybrid/rrf.md). |

## Warnings and Notices During a Build

A build continues after each of these.

| Message | Meaning |
| - | - |
| `only N parallel workers were available for index build` | The build is slower than it could be. Raise `max_parallel_maintenance_workers` and `max_parallel_workers`. |
| `` `maintenance_work_mem` only fits N training samples per vector partition `` | The build had less memory than it wanted. The message names a value that is enough. |
| `ivf training sample limited to N vectors by memory budget` | Clusters were trained on a smaller sample than intended. Raise `maintenance_work_mem` if recall matters more than build time. |
| `ivf minimum training sample of N vectors exceeds memory budget` | Same cause, and training was slower. Raise `maintenance_work_mem`. |
| `ivf_build timings_ms ...`, `pg_search index build "x": ...` | Informational. |
| `skipped N segment(s) with unsupported vector storage during merge` | Raised by a merge after an upgrade. Run `REINDEX`. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.