Skip to content

pg_vectorsearch 0.2.0

Latest

Choose a tag to compare

@vectorsearch-bot vectorsearch-bot released this 20 Nov 22:08
· 1 commit to main since this release
Immutable release. Only release title and notes can be modified.

Highlights

This release follows 0.1.0 with new features, faster queries, a more
compact index and bug fixes. It is still alpha quality. The on-disk
format changed, so every prism index has to be rebuilt with REINDEX
after the upgrade.

  • Wider vectors. PRISM indexes vectors of up to 8192 dimensions, up
    from 1968. Up to 1968 any dimension works. Above that the dimension
    must be a power of two times an odd factor of at most 8, such as
    2048, 3072, 4096, 6144 or 8192. Inner-product indexes stop lower
    (see Known issues). The README's "Dimensions" section has the
    details.
  • A more compact index. A posting list's codes now run on from one
    page to the next. Before, each group of codes had to fit whole on a
    page, which could leave up to half of the page empty. Each list also
    stores its reference vector as float16, half the size. Fewer pages
    per list means fewer pages read per query.
  • Faster queries. Fastscan scoring now applies at every dimension. It
    used to stop at 944. Queries with a large LIMIT no longer slow
    down out of proportion to the LIMIT
    (#369, #373).
  • l2_norm and vector_dims take pgvector's names, so the same query
    works on pgvector and pg_vectorsearch columns.

New index option:

  • posting_reference_format (float16 or float32, default
    float16) sets how each posting list stores its reference vector.
    The build or a split fails if an element of a reference is beyond
    65504, float16's largest value. Use float32 then. Vectors with an
    L2 norm up to 65504, and every cosine index, are always safe.

Breaking changes & upgrade notes

  • Indexes must be rebuilt. The on-disk index format changed (0x06 -> 0x07),
    so indexes built by earlier versions are rejected at open and have to be
    recreated.
  • vec32_norm is renamed to l2_norm, for both vec32 and vec16.
    vec32_dims(vec16) is renamed to vec16_dims. vec32_dims(vec32)
    keeps its name. Queries that call the old names must change. Views
    and indexes that use them keep working, because a rename keeps the
    function's OID.
  • vec16 refuses a value float16 cannot hold (beyond about ±65504) with
    an "out of range" error, as pgvector's halfvec does.

Upgrade from 0.1.0 with ALTER EXTENSION pg_vectorsearch UPDATE. Run it
in a new session that has not used the extension yet. The 0.2.0 library
refuses to load next to the 0.1.0 one. Then REINDEX each prism index.

Known issues

  • A WHERE filter can return fewer rows than LIMIT when the rows
    that pass are not spread through the candidates the scan ranked. The
    scan does not go back for more
    (#188).
  • The number of rows an ordered scan can return is capped by a buffer
    sized from work_mem. A larger LIMIT, or no LIMIT at all, is
    silently truncated to what fits (or to the table's estimated row
    count, if smaller). Raise work_mem to return more rows.
  • prism_rebalance leaves the posting lists it replaced on disk. Only
    REINDEX reclaims that space
    (#224).
  • Setting prism.leaf_refine_threshold above 0 can build an index with
    much lower recall. Leave it at 0
    (#183).
  • An inner-product index is limited to 1968 dimensions on a vec32
    column and 3584 on a vec16 column. CREATE INDEX fails above
    that. Use L2 or cosine for wider vectors. Normalized embeddings rank
    the same under cosine.
  • prism refuses unlogged tables and expression indexes.

Thanks

Changes

  • Indexes on vectors of up to 8192 dimensions
    (25e4dea)
  • Posting-list codes continue across pages, so pages are filled and
    fastscan works at every dimension
    (526c1bd)
  • Posting lists store their reference vector as float16, with the
    posting_reference_format index option to keep float32
    (ae2a75f)
  • Faster queries with a large LIMIT. Collecting and deduplicating
    the candidates no longer grows faster than the LIMIT does
    (5876aaf,
    e7595f6)
  • Faster searches from less per-page overhead in the centroid search
    and the fastscan posting scan
    (9f90dda,
    136c4a2)
  • Faster vec32 and vec16 distance operators on ARM (NEON)
    (29870c9)
  • Fixed wrong results from a scan after another session converted a
    posting list to the fastscan layout
    (d9281db)
  • Fixed a scan missing a row that had been HOT-updated, and a split
    dropping rows that an older snapshot still needed
    (1ffa59f)
  • Fixed a scan left open across a prism_rebalance, such as a cursor,
    reading freed memory
    (32f0091)
  • Fixed parallel index builds on toasted vectors growing memory
    without bound
    (93567fd)
  • The prism_* inspection and maintenance functions error on an index
    that is not a prism index instead of misreading it
    (ca2ea61)
  • Fixed a role with no privileges on a table being able to block
    VACUUM and DDL on it by calling a maintenance procedure
    (4bd921d)

Full changelog