mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-22 20:15:46 +08:00
Compare commits
1 Commits
v0.8.3
...
hnsw-tidst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7c2068b76 |
@@ -1,4 +1,4 @@
|
||||
## 0.8.3 (2026-06-17)
|
||||
## 0.8.3 (unreleased)
|
||||
|
||||
- Fixed possible index corruption with HNSW vacuuming
|
||||
- Fixed performance regression with Hamming distance and Jaccard distance with Postgres 18
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG DEBIAN_CODENAME=bookworm
|
||||
FROM postgres:$PG_MAJOR-$DEBIAN_CODENAME
|
||||
ARG PG_MAJOR
|
||||
|
||||
ADD https://github.com/pgvector/pgvector.git#v0.8.3 /tmp/pgvector
|
||||
ADD https://github.com/pgvector/pgvector.git#v0.8.2 /tmp/pgvector
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-mark hold locales && \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "vector",
|
||||
"abstract": "Open-source vector similarity search for Postgres",
|
||||
"description": "Supports L2 distance, inner product, and cosine distance",
|
||||
"version": "0.8.3",
|
||||
"version": "0.8.2",
|
||||
"maintainer": [
|
||||
"Andrew Kane <andrew@ankane.org>"
|
||||
],
|
||||
@@ -20,7 +20,7 @@
|
||||
"vector": {
|
||||
"file": "sql/vector.sql",
|
||||
"docfile": "README.md",
|
||||
"version": "0.8.3",
|
||||
"version": "0.8.2",
|
||||
"abstract": "Open-source vector similarity search for Postgres"
|
||||
}
|
||||
},
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
||||
EXTENSION = vector
|
||||
EXTVERSION = 0.8.3
|
||||
EXTVERSION = 0.8.2
|
||||
|
||||
MODULE_big = vector
|
||||
DATA = $(wildcard sql/*--*--*.sql)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EXTENSION = vector
|
||||
EXTVERSION = 0.8.3
|
||||
EXTVERSION = 0.8.2
|
||||
|
||||
DATA_built = sql\$(EXTENSION)--$(EXTVERSION).sql
|
||||
OBJS = src\bitutils.obj src\bitvec.obj src\halfutils.obj src\halfvec.obj src\hnsw.obj src\hnswbuild.obj src\hnswinsert.obj src\hnswscan.obj src\hnswutils.obj src\hnswvacuum.obj src\ivfbuild.obj src\ivfflat.obj src\ivfinsert.obj src\ivfkmeans.obj src\ivfscan.obj src\ivfutils.obj src\ivfvacuum.obj src\sparsevec.obj src\vector.obj
|
||||
|
||||
30
README.md
30
README.md
@@ -23,7 +23,7 @@ Compile and install the extension (supports Postgres 13+)
|
||||
|
||||
```sh
|
||||
cd /tmp
|
||||
git clone --branch v0.8.3 https://github.com/pgvector/pgvector.git
|
||||
git clone --branch v0.8.2 https://github.com/pgvector/pgvector.git
|
||||
cd pgvector
|
||||
make
|
||||
make install # may need sudo
|
||||
@@ -40,7 +40,7 @@ Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/buil
|
||||
```cmd
|
||||
set "PGROOT=C:\Program Files\PostgreSQL\18"
|
||||
cd %TEMP%
|
||||
git clone --branch v0.8.3 https://github.com/pgvector/pgvector.git
|
||||
git clone --branch v0.8.2 https://github.com/pgvector/pgvector.git
|
||||
cd pgvector
|
||||
nmake /F Makefile.win
|
||||
nmake /F Makefile.win install
|
||||
@@ -1151,23 +1151,23 @@ This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (r
|
||||
|
||||
Supported tags are:
|
||||
|
||||
- `pg18-trixie`, `0.8.3-pg18-trixie`
|
||||
- `pg18-bookworm`, `0.8.3-pg18-bookworm`, `pg18`, `0.8.3-pg18`
|
||||
- `pg17-trixie`, `0.8.3-pg17-trixie`
|
||||
- `pg17-bookworm`, `0.8.3-pg17-bookworm`, `pg17`, `0.8.3-pg17`
|
||||
- `pg16-trixie`, `0.8.3-pg16-trixie`
|
||||
- `pg16-bookworm`, `0.8.3-pg16-bookworm`, `pg16`, `0.8.3-pg16`
|
||||
- `pg15-trixie`, `0.8.3-pg15-trixie`
|
||||
- `pg15-bookworm`, `0.8.3-pg15-bookworm`, `pg15`, `0.8.3-pg15`
|
||||
- `pg14-trixie`, `0.8.3-pg14-trixie`
|
||||
- `pg14-bookworm`, `0.8.3-pg14-bookworm`, `pg14`, `0.8.3-pg14`
|
||||
- `pg13-trixie`, `0.8.3-pg13-trixie`
|
||||
- `pg13-bookworm`, `0.8.3-pg13-bookworm`, `pg13`, `0.8.3-pg13`
|
||||
- `pg18-trixie`, `0.8.2-pg18-trixie`
|
||||
- `pg18-bookworm`, `0.8.2-pg18-bookworm`, `pg18`, `0.8.2-pg18`
|
||||
- `pg17-trixie`, `0.8.2-pg17-trixie`
|
||||
- `pg17-bookworm`, `0.8.2-pg17-bookworm`, `pg17`, `0.8.2-pg17`
|
||||
- `pg16-trixie`, `0.8.2-pg16-trixie`
|
||||
- `pg16-bookworm`, `0.8.2-pg16-bookworm`, `pg16`, `0.8.2-pg16`
|
||||
- `pg15-trixie`, `0.8.2-pg15-trixie`
|
||||
- `pg15-bookworm`, `0.8.2-pg15-bookworm`, `pg15`, `0.8.2-pg15`
|
||||
- `pg14-trixie`, `0.8.2-pg14-trixie`
|
||||
- `pg14-bookworm`, `0.8.2-pg14-bookworm`, `pg14`, `0.8.2-pg14`
|
||||
- `pg13-trixie`, `0.8.2-pg13-trixie`
|
||||
- `pg13-bookworm`, `0.8.2-pg13-bookworm`, `pg13`, `0.8.2-pg13`
|
||||
|
||||
You can also build the image manually:
|
||||
|
||||
```sh
|
||||
git clone --branch v0.8.3 https://github.com/pgvector/pgvector.git
|
||||
git clone --branch v0.8.2 https://github.com/pgvector/pgvector.git
|
||||
cd pgvector
|
||||
docker build --pull --build-arg PG_MAJOR=18 -t myuser/pgvector .
|
||||
```
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
||||
\echo Use "ALTER EXTENSION vector UPDATE TO '0.8.3'" to load this file. \quit
|
||||
10
src/hnsw.c
10
src/hnsw.c
@@ -290,7 +290,11 @@ hnswhandler(PG_FUNCTION_ARGS)
|
||||
.amcanparallel = false,
|
||||
.amcanbuildparallel = true,
|
||||
.amcaninclude = false,
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
.amusemaintenanceworkmem = true,
|
||||
#else
|
||||
.amusemaintenanceworkmem = false,
|
||||
#endif
|
||||
.amsummarizing = false,
|
||||
.amparallelvacuumoptions = VACUUM_OPTION_PARALLEL_BULKDEL,
|
||||
.amkeytype = InvalidOid,
|
||||
@@ -351,7 +355,11 @@ hnswhandler(PG_FUNCTION_ARGS)
|
||||
amroutine->amcanbuildparallel = true;
|
||||
#endif
|
||||
amroutine->amcaninclude = false;
|
||||
amroutine->amusemaintenanceworkmem = false; /* not used during VACUUM */
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
amroutine->amusemaintenanceworkmem = true;
|
||||
#else
|
||||
amroutine->amusemaintenanceworkmem = false;
|
||||
#endif
|
||||
#if PG_VERSION_NUM >= 160000
|
||||
amroutine->amsummarizing = false;
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
typedef Pointer Item;
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
#define HnswTidStore TidStore
|
||||
#else
|
||||
#define HnswTidStore tidhash_hash
|
||||
#endif
|
||||
|
||||
#define HNSW_MAX_DIM 2000
|
||||
#define HNSW_MAX_NNZ 1000
|
||||
|
||||
@@ -427,7 +433,7 @@ typedef struct HnswVacuumState
|
||||
HnswSupport support;
|
||||
|
||||
/* Variables */
|
||||
struct tidhash_hash *deleted;
|
||||
struct HnswTidStore *deleted;
|
||||
BufferAccessStrategy bas;
|
||||
HnswNeighborTuple ntup;
|
||||
HnswElementData highestPoint;
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
#include "access/tidstore.h"
|
||||
#include "miscadmin.h"
|
||||
#include "postmaster/autovacuum.h"
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= 160000
|
||||
#include "varatt.h"
|
||||
#endif
|
||||
@@ -22,9 +28,13 @@
|
||||
* Check if deleted list contains an index TID
|
||||
*/
|
||||
static bool
|
||||
DeletedContains(tidhash_hash * deleted, ItemPointer indextid)
|
||||
DeletedContains(HnswTidStore * deleted, ItemPointer indextid)
|
||||
{
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
return TidStoreIsMember(deleted, indextid);
|
||||
#else
|
||||
return tidhash_lookup(deleted, *indextid) != NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -60,6 +70,10 @@ RemoveHeapTids(HnswVacuumState * vacuumstate)
|
||||
OffsetNumber offno;
|
||||
OffsetNumber maxoffno;
|
||||
bool updated = false;
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
OffsetNumber deletedoffs[MaxOffsetNumber];
|
||||
int ndeletedoffs = 0;
|
||||
#endif
|
||||
|
||||
vacuum_delay_point();
|
||||
|
||||
@@ -113,6 +127,9 @@ RemoveHeapTids(HnswVacuumState * vacuumstate)
|
||||
|
||||
if (!ItemPointerIsValid(&etup->heaptids[0]))
|
||||
{
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
deletedoffs[ndeletedoffs++] = offno;
|
||||
#else
|
||||
ItemPointerData ip;
|
||||
bool found;
|
||||
|
||||
@@ -121,6 +138,7 @@ RemoveHeapTids(HnswVacuumState * vacuumstate)
|
||||
|
||||
tidhash_insert(vacuumstate->deleted, ip, &found);
|
||||
Assert(!found);
|
||||
#endif
|
||||
}
|
||||
else if (etup->level > highestLevel)
|
||||
{
|
||||
@@ -149,6 +167,10 @@ RemoveHeapTids(HnswVacuumState * vacuumstate)
|
||||
}
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
TidStoreSetBlockOffsets(vacuumstate->deleted, blkno, deletedoffs, ndeletedoffs);
|
||||
#endif
|
||||
|
||||
blkno = HnswPageGetOpaque(page)->nextblkno;
|
||||
|
||||
if (updated)
|
||||
@@ -482,7 +504,7 @@ RepairGraph(HnswVacuumState * vacuumstate)
|
||||
MemoryContextReset(vacuumstate->tmpCtx);
|
||||
|
||||
#ifdef HNSW_VACUUM_PROGRESS
|
||||
if (!BlockNumberIsValid(blkno) || (blkno - HNSW_HEAD_BLKNO) % 1000 == 0)
|
||||
if (!BlockNumberIsValid(blkno) || ((blkno - HNSW_HEAD_BLKNO) % 1000 == 0 && blkno != HNSW_HEAD_BLKNO))
|
||||
{
|
||||
BlockNumber totalBlocks = RelationGetNumberOfBlocks(index);
|
||||
BlockNumber currentBlocks = BlockNumberIsValid(blkno) ? blkno : totalBlocks;
|
||||
@@ -739,7 +761,11 @@ InitVacuumState(HnswVacuumState * vacuumstate, IndexVacuumInfo *info, IndexBulkD
|
||||
HnswGetMetaPageInfo(index, &vacuumstate->m, NULL);
|
||||
|
||||
/* Create hash table */
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
vacuumstate->deleted = TidStoreCreateLocal((AmAutoVacuumWorkerProcess() && autovacuum_work_mem != -1) ? autovacuum_work_mem : maintenance_work_mem, true);
|
||||
#else
|
||||
vacuumstate->deleted = tidhash_create(CurrentMemoryContext, 256, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -748,7 +774,11 @@ InitVacuumState(HnswVacuumState * vacuumstate, IndexVacuumInfo *info, IndexBulkD
|
||||
static void
|
||||
FreeVacuumState(HnswVacuumState * vacuumstate)
|
||||
{
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
TidStoreDestroy(vacuumstate->deleted);
|
||||
#else
|
||||
tidhash_destroy(vacuumstate->deleted);
|
||||
#endif
|
||||
FreeAccessStrategy(vacuumstate->bas);
|
||||
pfree(vacuumstate->ntup);
|
||||
MemoryContextDelete(vacuumstate->tmpCtx);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= 180000
|
||||
PG_MODULE_MAGIC_EXT(.name = "vector", .version = "0.8.3");
|
||||
PG_MODULE_MAGIC_EXT(.name = "vector", .version = "0.8.2");
|
||||
#else
|
||||
PG_MODULE_MAGIC;
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
comment = 'vector data type and ivfflat and hnsw access methods'
|
||||
default_version = '0.8.3'
|
||||
default_version = '0.8.2'
|
||||
module_pathname = '$libdir/vector'
|
||||
relocatable = true
|
||||
|
||||
Reference in New Issue
Block a user