Skip to main content
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. 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:
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.

Recall Is Low

First measure recall with the same filter and LIMIT the application uses.

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

Warnings and Notices During a Build

A build continues after each of these.