From 7cf998069669c703fbd32ff7c6e1f350b12cbe1d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 13 Feb 2025 10:04:22 -0800 Subject: [PATCH 01/85] Updated Windows installation notes for Postgres 17.3 - closes #669 [skip ci] --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 04e795343..7d6e727b9 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,6 @@ nmake /F Makefile.win nmake /F Makefile.win install ``` -Note: Postgres 17 is not supported with MSVC yet due to an [upstream issue](https://www.postgresql.org/message-id/flat/CAOdR5yF0krWrxycA04rgUKCgKugRvGWzzGLAhDZ9bzNv8g0Lag%40mail.gmail.com) - See the [installation notes](#installation-notes---windows) if you run into issues You can also install it with [Docker](#docker) or [conda-forge](#conda-forge). @@ -1139,6 +1137,10 @@ make OPTFLAGS="" If compilation fails with `Cannot open include file: 'postgres.h': No such file or directory`, make sure `PGROOT` is correct. +### Missing Symbol + +If linking fails with `unresolved external symbol float_to_shortest_decimal_bufn` with Postgres 17.0-17.2, upgrade to Postgres 17.3+. + ### Permissions If installation fails with `Access is denied`, re-run the installation instructions as an administrator. From 656b059258e04c4c67ad8f5a927058b2ab5ecdcb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 13 Feb 2025 16:28:14 -0800 Subject: [PATCH 02/85] Added tests for iterative index scan with empty index - resolves #679 [skip ci] --- test/expected/hnsw_vector.out | 6 ++++++ test/expected/ivfflat_vector.out | 9 +++++++++ test/sql/hnsw_vector.sql | 3 +++ test/sql/ivfflat_vector.sql | 3 +++ 4 files changed, 21 insertions(+) diff --git a/test/expected/hnsw_vector.out b/test/expected/hnsw_vector.out index 29ea724e9..cb4d8b97b 100644 --- a/test/expected/hnsw_vector.out +++ b/test/expected/hnsw_vector.out @@ -123,6 +123,12 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; [0,0,0] (3 rows) +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + val +----- +(0 rows) + RESET hnsw.iterative_scan; RESET hnsw.ef_search; DROP TABLE t; diff --git a/test/expected/ivfflat_vector.out b/test/expected/ivfflat_vector.out index 5a6bc757c..aad8226c1 100644 --- a/test/expected/ivfflat_vector.out +++ b/test/expected/ivfflat_vector.out @@ -110,6 +110,15 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; [1,1,1] (2 rows) +TRUNCATE t; +NOTICE: ivfflat index created with little data +DETAIL: This will cause low recall. +HINT: Drop the index until the table has more data. +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + val +----- +(0 rows) + RESET ivfflat.iterative_scan; RESET ivfflat.max_probes; DROP TABLE t; diff --git a/test/sql/hnsw_vector.sql b/test/sql/hnsw_vector.sql index 184d65faf..a928ba44e 100644 --- a/test/sql/hnsw_vector.sql +++ b/test/sql/hnsw_vector.sql @@ -70,6 +70,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; SET hnsw.iterative_scan = relaxed_order; SELECT * FROM t ORDER BY val <-> '[3,3,3]'; +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + RESET hnsw.iterative_scan; RESET hnsw.ef_search; DROP TABLE t; diff --git a/test/sql/ivfflat_vector.sql b/test/sql/ivfflat_vector.sql index 785fc6c0f..4c20d2faf 100644 --- a/test/sql/ivfflat_vector.sql +++ b/test/sql/ivfflat_vector.sql @@ -59,6 +59,9 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; SET ivfflat.max_probes = 2; SELECT * FROM t ORDER BY val <-> '[3,3,3]'; +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + RESET ivfflat.iterative_scan; RESET ivfflat.max_probes; DROP TABLE t; From aafdf4167d693d6e9ba760af31d103f562408733 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 17 Feb 2025 13:16:31 -0800 Subject: [PATCH 03/85] Improved missing SDK docs [skip ci] --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d6e727b9..3e5b9d803 100644 --- a/README.md +++ b/README.md @@ -1119,7 +1119,13 @@ Note: Replace `17` with your Postgres server version ### Missing SDK -If compilation fails and the output includes `warning: no such sysroot directory` on Mac, reinstall Xcode Command Line Tools. +If compilation fails and the output includes `warning: no such sysroot directory` on Mac, your Postgres installation points to a path that no longer exists. + +```sh +pg_config --ldflags +``` + +Reinstall Postgres to fix this. ### Portability From f11e4d7b2095d205edc4af6163aef4063f59c60b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 17 Feb 2025 13:22:50 -0800 Subject: [PATCH 04/85] Updated readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e5b9d803..6b33e8e16 100644 --- a/README.md +++ b/README.md @@ -1122,7 +1122,7 @@ Note: Replace `17` with your Postgres server version If compilation fails and the output includes `warning: no such sysroot directory` on Mac, your Postgres installation points to a path that no longer exists. ```sh -pg_config --ldflags +pg_config --cppflags ``` Reinstall Postgres to fix this. From 78ed8f11576c77a0a6b5fc0ebf721a3dc4f4c954 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 17 Feb 2025 16:38:14 -0800 Subject: [PATCH 05/85] Fixed compilation error with Postgres 18 - fixes #779 --- src/hnswvacuum.c | 4 ++++ src/ivfvacuum.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 251d9d9ad..2f7b2f372 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -9,6 +9,10 @@ #include "storage/lmgr.h" #include "utils/memutils.h" +#if PG_VERSION_NUM >= 180000 +#define vacuum_delay_point() vacuum_delay_point(false) +#endif + /* * Check if deleted list contains an index TID */ diff --git a/src/ivfvacuum.c b/src/ivfvacuum.c index 1272da831..750cdd65a 100644 --- a/src/ivfvacuum.c +++ b/src/ivfvacuum.c @@ -5,6 +5,10 @@ #include "ivfflat.h" #include "storage/bufmgr.h" +#if PG_VERSION_NUM >= 180000 +#define vacuum_delay_point() vacuum_delay_point(false) +#endif + /* * Bulk delete tuples from the index */ From fef635c9e5512597621e5669dce845c744170822 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 20 Feb 2025 00:05:35 -0800 Subject: [PATCH 06/85] Updated readme [skip ci] --- README.md | 82 ++++++++++++++----------------------------------------- 1 file changed, 21 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 6b33e8e16..08f36ed21 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Get the nearest neighbors by L2 distance SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5; ``` -Also supports inner product (`<#>`), cosine distance (`<=>`), and L1 distance (`<+>`, added in 0.7.0) +Also supports inner product (`<#>`), cosine distance (`<=>`), and L1 distance (`<+>`) Note: `<#>` returns the negative inner product since Postgres only supports `ASC` order index scans on operators @@ -146,9 +146,9 @@ Supported distance functions are: - `<->` - L2 distance - `<#>` - (negative) inner product - `<=>` - cosine distance -- `<+>` - L1 distance (added in 0.7.0) -- `<~>` - Hamming distance (binary vectors, added in 0.7.0) -- `<%>` - Jaccard distance (binary vectors, added in 0.7.0) +- `<+>` - L1 distance +- `<~>` - Hamming distance (binary vectors) +- `<%>` - Jaccard distance (binary vectors) Get the nearest neighbors to a row @@ -235,19 +235,19 @@ Cosine distance CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops); ``` -L1 distance - added in 0.7.0 +L1 distance ```sql CREATE INDEX ON items USING hnsw (embedding vector_l1_ops); ``` -Hamming distance - added in 0.7.0 +Hamming distance ```sql CREATE INDEX ON items USING hnsw (embedding bit_hamming_ops); ``` -Jaccard distance - added in 0.7.0 +Jaccard distance ```sql CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops); @@ -256,9 +256,9 @@ CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops); Supported types are: - `vector` - up to 2,000 dimensions -- `halfvec` - up to 4,000 dimensions (added in 0.7.0) -- `bit` - up to 64,000 dimensions (added in 0.7.0) -- `sparsevec` - up to 1,000 non-zero elements (added in 0.7.0) +- `halfvec` - up to 4,000 dimensions +- `bit` - up to 64,000 dimensions +- `sparsevec` - up to 1,000 non-zero elements ### Index Options @@ -312,7 +312,7 @@ Note: Do not set `maintenance_work_mem` so high that it exhausts the memory on t Like other index types, it’s faster to create an index after loading your initial data -Starting with 0.6.0, you can also speed up index creation by increasing the number of parallel workers (2 by default) +You can also speed up index creation by increasing the number of parallel workers (2 by default) ```sql SET max_parallel_maintenance_workers = 7; -- plus leader @@ -365,7 +365,7 @@ Cosine distance CREATE INDEX ON items USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100); ``` -Hamming distance - added in 0.7.0 +Hamming distance ```sql CREATE INDEX ON items USING ivfflat (embedding bit_hamming_ops) WITH (lists = 100); @@ -374,8 +374,8 @@ CREATE INDEX ON items USING ivfflat (embedding bit_hamming_ops) WITH (lists = 10 Supported types are: - `vector` - up to 2,000 dimensions -- `halfvec` - up to 4,000 dimensions (added in 0.7.0) -- `bit` - up to 64,000 dimensions (added in 0.7.0) +- `halfvec` - up to 4,000 dimensions +- `bit` - up to 64,000 dimensions ### Query Options @@ -547,8 +547,6 @@ Note: If this is lower than `ivfflat.probes`, `ivfflat.probes` will be used ## Half-Precision Vectors -*Added in 0.7.0* - Use the `halfvec` type to store half-precision vectors ```sql @@ -557,8 +555,6 @@ CREATE TABLE items (id bigserial PRIMARY KEY, embedding halfvec(3)); ## Half-Precision Indexing -*Added in 0.7.0* - Index vectors at half precision for smaller indexes ```sql @@ -580,24 +576,16 @@ CREATE TABLE items (id bigserial PRIMARY KEY, embedding bit(3)); INSERT INTO items (embedding) VALUES ('000'), ('111'); ``` -Get the nearest neighbors by Hamming distance (added in 0.7.0) +Get the nearest neighbors by Hamming distance ```sql SELECT * FROM items ORDER BY embedding <~> '101' LIMIT 5; ``` -Or (before 0.7.0) - -```sql -SELECT * FROM items ORDER BY bit_count(embedding # '101') LIMIT 5; -``` - Also supports Jaccard distance (`<%>`) ## Binary Quantization -*Added in 0.7.0* - Use expression indexing for binary quantization ```sql @@ -620,8 +608,6 @@ SELECT * FROM ( ## Sparse Vectors -*Added in 0.7.0* - Use the `sparsevec` type to store sparse vectors ```sql @@ -655,8 +641,6 @@ You can use [Reciprocal Rank Fusion](https://github.com/pgvector/pgvector-python ## Indexing Subvectors -*Added in 0.7.0* - Use expression indexing to index subvectors ```sql @@ -1171,6 +1155,12 @@ cd pgvector docker build --pull --build-arg PG_MAJOR=17 -t myuser/pgvector . ``` +If you increase `maintenance_work_mem`, make sure `--shm-size` is at least that size to avoid an error with parallel HNSW index builds. + +```sh +docker run --shm-size=1g ... +``` + ### Homebrew With Homebrew Postgres, you can use: @@ -1258,36 +1248,6 @@ You can check the version in the current database with: SELECT extversion FROM pg_extension WHERE extname = 'vector'; ``` -## Upgrade Notes - -### 0.6.0 - -#### Postgres 12 - -If upgrading with Postgres 12, remove this line from `sql/vector--0.5.1--0.6.0.sql`: - -```sql -ALTER TYPE vector SET (STORAGE = external); -``` - -Then run `make install` and `ALTER EXTENSION vector UPDATE;`. - -#### Docker - -The Docker image is now published in the `pgvector` org, and there are tags for each supported version of Postgres (rather than a `latest` tag). - -```sh -docker pull pgvector/pgvector:pg16 -# or -docker pull pgvector/pgvector:0.6.0-pg16 -``` - -Also, if you’ve increased `maintenance_work_mem`, make sure `--shm-size` is at least that size to avoid an error with parallel HNSW index builds. - -```sh -docker run --shm-size=1g ... -``` - ## Thanks Thanks to: From 880dc4d6b94f1cc4e6048edd732282511bf5995c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 23 Mar 2025 11:51:10 -0700 Subject: [PATCH 07/85] Added Windows installation note about mismatched architecture - #593 #797 #804 [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 08f36ed21..67c86a94f 100644 --- a/README.md +++ b/README.md @@ -1127,6 +1127,10 @@ make OPTFLAGS="" If compilation fails with `Cannot open include file: 'postgres.h': No such file or directory`, make sure `PGROOT` is correct. +### Mismatched Architecture + +If compilation fails with `error C2196: case value '4' already used`, make sure `vcvars64.bat` was called. + ### Missing Symbol If linking fails with `unresolved external symbol float_to_shortest_decimal_bufn` with Postgres 17.0-17.2, upgrade to Postgres 17.3+. From 4af2b06dc557df48ea15cc72c978aa430d52414f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 23 Mar 2025 14:59:28 -0700 Subject: [PATCH 08/85] Improved installation note [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 67c86a94f..a1077cd45 100644 --- a/README.md +++ b/README.md @@ -1129,7 +1129,7 @@ If compilation fails with `Cannot open include file: 'postgres.h': No such file ### Mismatched Architecture -If compilation fails with `error C2196: case value '4' already used`, make sure `vcvars64.bat` was called. +If compilation fails with `error C2196: case value '4' already used`, make sure `vcvars64.bat` was called. Then run `nmake /F Makefile.win clean` and re-run the installation instructions. ### Missing Symbol From cc0958dec51b2b49ba6e3eeda5788d85d173a6e5 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 24 Mar 2025 19:18:01 -0700 Subject: [PATCH 09/85] Removed deprecated runner image [skip ci] --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27c989d29..e0a0cb038 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,13 +13,13 @@ jobs: - postgres: 17 os: ubuntu-24.04 - postgres: 16 - os: ubuntu-22.04 + os: ubuntu-24.04 - postgres: 15 os: ubuntu-22.04 - postgres: 14 - os: ubuntu-20.04 + os: ubuntu-22.04 - postgres: 13 - os: ubuntu-20.04 + os: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: ankane/setup-postgres@v1 From 05182479a2a62e04300386b4da18be02fcb819b5 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 24 Mar 2025 19:26:52 -0700 Subject: [PATCH 10/85] Added ARM to CI [skip ci] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0a0cb038..e58c3b56d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,11 +13,11 @@ jobs: - postgres: 17 os: ubuntu-24.04 - postgres: 16 - os: ubuntu-24.04 + os: ubuntu-24.04-arm - postgres: 15 os: ubuntu-22.04 - postgres: 14 - os: ubuntu-22.04 + os: ubuntu-22.04-arm - postgres: 13 os: ubuntu-22.04 steps: From d365aac370b3313f3989c09a55cd4f2fd65688b6 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 26 Mar 2025 11:56:38 -0700 Subject: [PATCH 11/85] Added note about index options to index build time docs - #807 [skip ci] --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1077cd45..1ee996b94 100644 --- a/README.md +++ b/README.md @@ -318,7 +318,9 @@ You can also speed up index creation by increasing the number of parallel worker SET max_parallel_maintenance_workers = 7; -- plus leader ``` -For a large number of workers, you may also need to increase `max_parallel_workers` (8 by default) +For a large number of workers, you may need to increase `max_parallel_workers` (8 by default) + +The [index options](#index-options) also have a significant impact on build time (use the defaults unless seeing low recall) ### Indexing Progress From a03dc5b7d0aad1feb3ca41f8da5bfb5c70f54811 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 5 Apr 2025 11:31:57 -0700 Subject: [PATCH 12/85] Added fields to IndexAmRoutine for Postgres 18 [skip ci] --- src/hnsw.c | 13 +++++++++++++ src/ivfflat.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/hnsw.c b/src/hnsw.c index 5bfc6193e..ec7c98852 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -259,6 +259,11 @@ hnswhandler(PG_FUNCTION_ARGS) amroutine->amoptsprocnum = 0; amroutine->amcanorder = false; amroutine->amcanorderbyop = true; +#if PG_VERSION_NUM >= 180000 + amroutine->amcanhash = false; + amroutine->amconsistentequality = false; + amroutine->amconsistentordering = false; +#endif amroutine->amcanbackward = false; /* can change direction mid-scan */ amroutine->amcanunique = false; amroutine->amcanmulticol = false; @@ -291,6 +296,9 @@ hnswhandler(PG_FUNCTION_ARGS) amroutine->amvacuumcleanup = hnswvacuumcleanup; amroutine->amcanreturn = NULL; amroutine->amcostestimate = hnswcostestimate; +#if PG_VERSION_NUM >= 180000 + amroutine->amgettreeheight = NULL; +#endif amroutine->amoptions = hnswoptions; amroutine->amproperty = NULL; /* TODO AMPROP_DISTANCE_ORDERABLE */ amroutine->ambuildphasename = hnswbuildphasename; @@ -311,5 +319,10 @@ hnswhandler(PG_FUNCTION_ARGS) amroutine->aminitparallelscan = NULL; amroutine->amparallelrescan = NULL; +#if PG_VERSION_NUM >= 180000 + amroutine->amtranslatestrategy = NULL; + amroutine->amtranslatecmptype = NULL; +#endif + PG_RETURN_POINTER(amroutine); } diff --git a/src/ivfflat.c b/src/ivfflat.c index 9e8370ffe..736d537d1 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -186,6 +186,11 @@ ivfflathandler(PG_FUNCTION_ARGS) amroutine->amoptsprocnum = 0; amroutine->amcanorder = false; amroutine->amcanorderbyop = true; +#if PG_VERSION_NUM >= 180000 + amroutine->amcanhash = false; + amroutine->amconsistentequality = false; + amroutine->amconsistentordering = false; +#endif amroutine->amcanbackward = false; /* can change direction mid-scan */ amroutine->amcanunique = false; amroutine->amcanmulticol = false; @@ -218,6 +223,9 @@ ivfflathandler(PG_FUNCTION_ARGS) amroutine->amvacuumcleanup = ivfflatvacuumcleanup; amroutine->amcanreturn = NULL; /* tuple not included in heapsort */ amroutine->amcostestimate = ivfflatcostestimate; +#if PG_VERSION_NUM >= 180000 + amroutine->amgettreeheight = NULL; +#endif amroutine->amoptions = ivfflatoptions; amroutine->amproperty = NULL; /* TODO AMPROP_DISTANCE_ORDERABLE */ amroutine->ambuildphasename = ivfflatbuildphasename; @@ -238,5 +246,10 @@ ivfflathandler(PG_FUNCTION_ARGS) amroutine->aminitparallelscan = NULL; amroutine->amparallelrescan = NULL; +#if PG_VERSION_NUM >= 180000 + amroutine->amtranslatestrategy = NULL; + amroutine->amtranslatecmptype = NULL; +#endif + PG_RETURN_POINTER(amroutine); } From 32e95a8598200788bfc13fb1b9b8284b45f07eda Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 5 Apr 2025 12:13:38 -0700 Subject: [PATCH 13/85] Fixed warnings with Postgres 18 [skip ci] --- src/hnsw.c | 3 +++ src/ivfflat.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/hnsw.c b/src/hnsw.c index ec7c98852..d0d7086dd 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -223,6 +223,9 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * hnswoptions(Datum reloptions, bool validate) { +#if PG_VERSION_NUM >= 180000 +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif static const relopt_parse_elt tab[] = { {"m", RELOPT_TYPE_INT, offsetof(HnswOptions, m)}, {"ef_construction", RELOPT_TYPE_INT, offsetof(HnswOptions, efConstruction)}, diff --git a/src/ivfflat.c b/src/ivfflat.c index 736d537d1..9d95f1d19 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -151,6 +151,9 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * ivfflatoptions(Datum reloptions, bool validate) { +#if PG_VERSION_NUM >= 180000 +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif static const relopt_parse_elt tab[] = { {"lists", RELOPT_TYPE_INT, offsetof(IvfflatOptions, lists)}, }; From 35f4f7fc801962e73f73f4b5e6b7fd09c2f273fb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 5 Apr 2025 12:38:30 -0700 Subject: [PATCH 14/85] Improved warning check [skip ci] --- src/hnsw.c | 2 +- src/ivfflat.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index d0d7086dd..5d16ae36b 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -223,7 +223,7 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * hnswoptions(Datum reloptions, bool validate) { -#if PG_VERSION_NUM >= 180000 +#if PG_VERSION_NUM >= 180000 && defined(__GNUC__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif static const relopt_parse_elt tab[] = { diff --git a/src/ivfflat.c b/src/ivfflat.c index 9d95f1d19..3ff0299cb 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -151,7 +151,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * ivfflatoptions(Datum reloptions, bool validate) { -#if PG_VERSION_NUM >= 180000 +#if PG_VERSION_NUM >= 180000 && defined(__GNUC__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif static const relopt_parse_elt tab[] = { From e5758662973746b244ce62dbaccd7fa191a6ef8b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 5 Apr 2025 12:56:00 -0700 Subject: [PATCH 15/85] Revert "Fixed warnings with Postgres 18 [skip ci]" This reverts commit 32e95a8598200788bfc13fb1b9b8284b45f07eda. --- src/hnsw.c | 3 --- src/ivfflat.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index 5d16ae36b..ec7c98852 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -223,9 +223,6 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * hnswoptions(Datum reloptions, bool validate) { -#if PG_VERSION_NUM >= 180000 && defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif static const relopt_parse_elt tab[] = { {"m", RELOPT_TYPE_INT, offsetof(HnswOptions, m)}, {"ef_construction", RELOPT_TYPE_INT, offsetof(HnswOptions, efConstruction)}, diff --git a/src/ivfflat.c b/src/ivfflat.c index 3ff0299cb..736d537d1 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -151,9 +151,6 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, static bytea * ivfflatoptions(Datum reloptions, bool validate) { -#if PG_VERSION_NUM >= 180000 && defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif static const relopt_parse_elt tab[] = { {"lists", RELOPT_TYPE_INT, offsetof(IvfflatOptions, lists)}, }; From ebbfe8dba06400706b8fe32276e1c3b138feae5a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 5 Apr 2025 13:05:27 -0700 Subject: [PATCH 16/85] Fixed CI for Postgres 18 [skip ci] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e58c3b56d..f4022663c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: dev-files: true - run: make env: - PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare + PG_CFLAGS: ${{ matrix.postgres == 18 && '-Wno-missing-field-initializers' || '' }} -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare - run: | export PG_CONFIG=`which pg_config` sudo --preserve-env=PG_CONFIG make install From 83d410eae958dcdb5256b83b7104ec9b013409c4 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 13 Apr 2025 13:07:31 -0700 Subject: [PATCH 17/85] Updated readme [skip ci] --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 1ee996b94..ef56d354c 100644 --- a/README.md +++ b/README.md @@ -477,8 +477,6 @@ CREATE TABLE items (embedding vector(3), category_id int) PARTITION BY LIST(cate ## Iterative Index Scans -*Added in 0.8.0* - With approximate indexes, queries with filtering can return less results since filtering is applied *after* the index is scanned. Starting with 0.8.0, you can enable iterative index scans, which will automatically scan more of the index until enough results are found (or it reaches `hnsw.max_scan_tuples` or `ivfflat.max_probes`). Iterative scans can use strict or relaxed ordering. From 7b583523365f4b2ea7ec7ea2feab6836267c046e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 6 May 2025 21:39:51 -0700 Subject: [PATCH 18/85] Updated readme [skip ci] --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index ef56d354c..d8db12ad0 100644 --- a/README.md +++ b/README.md @@ -754,8 +754,6 @@ SELECT query, calls, ROUND((total_plan_time + total_exec_time) / calls) AS avg_t FROM pg_stat_statements ORDER BY total_plan_time + total_exec_time DESC LIMIT 20; ``` -Note: Replace `total_plan_time + total_exec_time` with `total_time` for Postgres < 13 - Monitor recall by comparing results from approximate search with exact search. ```sql @@ -824,7 +822,7 @@ You can use [half-precision indexing](#half-precision-indexing) to index up to 4 #### Can I store vectors with different dimensions in the same column? -You can use `vector` as the type (instead of `vector(3)`). +You can use `vector` as the type (instead of `vector(n)`). ```sql CREATE TABLE embeddings (model_id bigint, item_id bigint, embedding vector, PRIMARY KEY (model_id, item_id)); From e2efe62fe534d4b294766aeee07a98ea1dd0ea88 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 12 May 2025 13:11:43 -0700 Subject: [PATCH 19/85] Updated readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d8db12ad0..191e16865 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Note: The exact path will vary depending on your Visual Studio version and editi Then use `nmake` to build: ```cmd -set "PGROOT=C:\Program Files\PostgreSQL\16" +set "PGROOT=C:\Program Files\PostgreSQL\17" cd %TEMP% git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git cd pgvector From 3cd1f09f661fa38e209efab599ba7652f6dcedcd Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 4 Jun 2025 14:18:53 -0700 Subject: [PATCH 20/85] Updated Windows installation instructions - #593 [skip ci] --- README.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 191e16865..2fe18907e 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,7 @@ You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#p ### Windows -Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) is installed, and run: - -```cmd -call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" -``` - -Note: The exact path will vary depending on your Visual Studio version and edition - -Then use `nmake` to build: +Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) is installed and run `x64 Native Tools Command Prompt for VS 2022` as administrator. Then use `nmake` to build: ```cmd set "PGROOT=C:\Program Files\PostgreSQL\17" @@ -1127,7 +1119,7 @@ If compilation fails with `Cannot open include file: 'postgres.h': No such file ### Mismatched Architecture -If compilation fails with `error C2196: case value '4' already used`, make sure `vcvars64.bat` was called. Then run `nmake /F Makefile.win clean` and re-run the installation instructions. +If compilation fails with `error C2196: case value '4' already used`, make sure you’re using the `x64 Native Tools Command Prompt`. Then run `nmake /F Makefile.win clean` and re-run the installation instructions. ### Missing Symbol From 799cfebf704749e10389ed0874a01dd818e25b87 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 4 Jun 2025 14:29:53 -0700 Subject: [PATCH 21/85] Updated readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fe18907e..344971611 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#p ### Windows -Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) is installed and run `x64 Native Tools Command Prompt for VS 2022` as administrator. Then use `nmake` to build: +Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) is installed and run `x64 Native Tools Command Prompt for VS [version]` as administrator. Then use `nmake` to build: ```cmd set "PGROOT=C:\Program Files\PostgreSQL\17" From bf28ed8176cd19edbe30f7ccbc25fa299a8b0298 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 10:57:18 -0700 Subject: [PATCH 22/85] Set random seed for IVFFLAT_BENCH [skip ci] --- src/ivfbuild.c | 4 ++++ src/ivfflat.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 944f07b55..c51f40884 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -1023,6 +1023,10 @@ ivfflatbuild(Relation heap, Relation index, IndexInfo *indexInfo) IndexBuildResult *result; IvfflatBuildState buildstate; +#ifdef IVFFLAT_BENCH + SeedRandom(42); +#endif + BuildIndex(heap, index, indexInfo, &buildstate, MAIN_FORKNUM); result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult)); diff --git a/src/ivfflat.h b/src/ivfflat.h index c296b6677..76608f334 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -73,9 +73,11 @@ #if PG_VERSION_NUM >= 150000 #define RandomDouble() pg_prng_double(&pg_global_prng_state) #define RandomInt() pg_prng_uint32(&pg_global_prng_state) +#define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed) #else #define RandomDouble() (((double) random()) / MAX_RANDOM_VALUE) #define RandomInt() random() +#define SeedRandom(seed) srandom(seed) #endif /* Variables */ From fe697e878808383b3546db335ae47d61ffec57fa Mon Sep 17 00:00:00 2001 From: Jon Daniel Date: Wed, 18 Jun 2025 19:09:43 -0400 Subject: [PATCH 23/85] vectorize: optimize VectorSumCenter and HalfvecSumCenter (#860) * vectorize: optimize VectorSumCenter and HalfvecSumCenter The functions VectorSumCenter and HalfvecSumCenter were not being vectorized by the compiler. A few slight changes will allow these optimizations to take place and get a performance boost by utilizing SIMD instructions. This optimization helps improve performance of vector operations in IVF index building and updating. * Removing const, commenting that it is only vectoirzed on ARM --- src/ivfutils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ivfutils.c b/src/ivfutils.c index da241ee0a..044fbabf6 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -295,8 +295,10 @@ static void VectorSumCenter(Pointer v, float *x) { Vector *vec = (Vector *) v; + int dim = vec->dim; - for (int k = 0; k < vec->dim; k++) + /* Auto-vectorized */ + for (int k = 0; k < dim; k++) x[k] += vec->x[k]; } @@ -304,8 +306,10 @@ static void HalfvecSumCenter(Pointer v, float *x) { HalfVector *vec = (HalfVector *) v; + int dim = vec->dim; - for (int k = 0; k < vec->dim; k++) + /* Auto-vectorized on aarch64 */ + for (int k = 0; k < dim; k++) x[k] += HalfToFloat4(vec->x[k]); } From 8ad680f0093d0d64742e1e4d4f0e5e446da61399 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 16:11:15 -0700 Subject: [PATCH 24/85] Ran pgindent [skip ci] --- src/ivfutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ivfutils.c b/src/ivfutils.c index 044fbabf6..3f5535955 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -295,7 +295,7 @@ static void VectorSumCenter(Pointer v, float *x) { Vector *vec = (Vector *) v; - int dim = vec->dim; + int dim = vec->dim; /* Auto-vectorized */ for (int k = 0; k < dim; k++) @@ -306,7 +306,7 @@ static void HalfvecSumCenter(Pointer v, float *x) { HalfVector *vec = (HalfVector *) v; - int dim = vec->dim; + int dim = vec->dim; /* Auto-vectorized on aarch64 */ for (int k = 0; k < dim; k++) From 870ca6724db096ad9da34f31ce355fd4f552b7a8 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 16:26:30 -0700 Subject: [PATCH 25/85] Fixed CI [skip ci] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4022663c..a379e3682 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: postgres-version: ${{ matrix.postgres }} - run: make env: - PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter + PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-warning-option - run: make install - run: make installcheck - if: ${{ failure() }} From ce09c9a27a3688939b1c5f81b301d84cb727627b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 17:32:37 -0700 Subject: [PATCH 26/85] Improved variable names [skip ci] --- src/ivfutils.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ivfutils.c b/src/ivfutils.c index 3f5535955..9596391be 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -259,8 +259,8 @@ VectorUpdateCenter(Pointer v, int dimensions, float *x) SET_VARSIZE(vec, VECTOR_SIZE(dimensions)); vec->dim = dimensions; - for (int k = 0; k < dimensions; k++) - vec->x[k] = x[k]; + for (int i = 0; i < dimensions; i++) + vec->x[i] = x[i]; } static void @@ -271,8 +271,8 @@ HalfvecUpdateCenter(Pointer v, int dimensions, float *x) SET_VARSIZE(vec, HALFVEC_SIZE(dimensions)); vec->dim = dimensions; - for (int k = 0; k < dimensions; k++) - vec->x[k] = Float4ToHalfUnchecked(x[k]); + for (int i = 0; i < dimensions; i++) + vec->x[i] = Float4ToHalfUnchecked(x[i]); } static void @@ -284,11 +284,11 @@ BitUpdateCenter(Pointer v, int dimensions, float *x) SET_VARSIZE(vec, VARBITTOTALLEN(dimensions)); VARBITLEN(vec) = dimensions; - for (uint32 k = 0; k < VARBITBYTES(vec); k++) - nx[k] = 0; + for (uint32 i = 0; i < VARBITBYTES(vec); i++) + nx[i] = 0; - for (int k = 0; k < dimensions; k++) - nx[k / 8] |= (x[k] > 0.5 ? 1 : 0) << (7 - (k % 8)); + for (int i = 0; i < dimensions; i++) + nx[i / 8] |= (x[i] > 0.5 ? 1 : 0) << (7 - (i % 8)); } static void @@ -298,8 +298,8 @@ VectorSumCenter(Pointer v, float *x) int dim = vec->dim; /* Auto-vectorized */ - for (int k = 0; k < dim; k++) - x[k] += vec->x[k]; + for (int i = 0; i < dim; i++) + x[i] += vec->x[i]; } static void @@ -309,8 +309,8 @@ HalfvecSumCenter(Pointer v, float *x) int dim = vec->dim; /* Auto-vectorized on aarch64 */ - for (int k = 0; k < dim; k++) - x[k] += HalfToFloat4(vec->x[k]); + for (int i = 0; i < dim; i++) + x[i] += HalfToFloat4(vec->x[i]); } static void @@ -318,8 +318,8 @@ BitSumCenter(Pointer v, float *x) { VarBit *vec = (VarBit *) v; - for (int k = 0; k < VARBITLEN(vec); k++) - x[k] += (float) (((VARBITS(vec)[k / 8]) >> (7 - (k % 8))) & 0x01); + for (int i = 0; i < VARBITLEN(vec); i++) + x[i] += (float) (((VARBITS(vec)[i / 8]) >> (7 - (i % 8))) & 0x01); } /* From 3a49d141b32359eaa4ea3b00940cb928ee6befc4 Mon Sep 17 00:00:00 2001 From: Jon Daniel Date: Wed, 18 Jun 2025 23:06:32 -0400 Subject: [PATCH 27/85] Vectorizing vector_concat for improved performance (#861) * Vectorizing vector_concat for improved performance On an ARM chip this should generate SIMD instructions to copy the two incoming vectors to the new vector as opposed to doing it all in software. * Moving declarations to above CheckDim * Removing const from dims * Formatting --- src/vector.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vector.c b/src/vector.c index a5b2aac36..0ced82bbd 100644 --- a/src/vector.c +++ b/src/vector.c @@ -916,15 +916,19 @@ vector_concat(PG_FUNCTION_ARGS) Vector *b = PG_GETARG_VECTOR_P(1); Vector *result; int dim = a->dim + b->dim; + int dim_a = a->dim; + int dim_b = b->dim; CheckDim(dim); result = InitVector(dim); - for (int i = 0; i < a->dim; i++) + /* Auto-vectorized */ + for (int i = 0; i < dim_a; i++) result->x[i] = a->x[i]; - for (int i = 0; i < b->dim; i++) - result->x[i + a->dim] = b->x[i]; + /* Auto-vectorized */ + for (int i = 0; i < dim_b; i++) + result->x[i + dim_a] = b->x[i]; PG_RETURN_POINTER(result); } From e6bad96a0357d3861b83297f3688cfae8d621c75 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 20:07:46 -0700 Subject: [PATCH 28/85] Ran pgindent [skip ci] --- src/vector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector.c b/src/vector.c index 0ced82bbd..d2312e042 100644 --- a/src/vector.c +++ b/src/vector.c @@ -916,8 +916,8 @@ vector_concat(PG_FUNCTION_ARGS) Vector *b = PG_GETARG_VECTOR_P(1); Vector *result; int dim = a->dim + b->dim; - int dim_a = a->dim; - int dim_b = b->dim; + int dim_a = a->dim; + int dim_b = b->dim; CheckDim(dim); result = InitVector(dim); From fa1dee4e3b29aaf5031035877d770b22e327d5e3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 1 Jul 2025 03:35:26 -0700 Subject: [PATCH 29/85] Updated link [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 344971611..d4d2f49f6 100644 --- a/README.md +++ b/README.md @@ -783,7 +783,7 @@ Go | [pgvector-go](https://github.com/pgvector/pgvector-go) Haskell | [pgvector-haskell](https://github.com/pgvector/pgvector-haskell) Java, Kotlin, Groovy, Scala | [pgvector-java](https://github.com/pgvector/pgvector-java) JavaScript, TypeScript | [pgvector-node](https://github.com/pgvector/pgvector-node) -Julia | [pgvector-julia](https://github.com/pgvector/pgvector-julia) +Julia | [Pgvector.jl](https://github.com/pgvector/Pgvector.jl) Lisp | [pgvector-lisp](https://github.com/pgvector/pgvector-lisp) Lua | [pgvector-lua](https://github.com/pgvector/pgvector-lua) Nim | [pgvector-nim](https://github.com/pgvector/pgvector-nim) From ae9ee81e4de7e41569395a3d3dfc86253dadcd02 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 1 Jul 2025 10:11:50 -0700 Subject: [PATCH 30/85] Fixed relaxed results example for Postgres 17 - #862 [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4d2f49f6..ab8a06dd3 100644 --- a/README.md +++ b/README.md @@ -492,7 +492,7 @@ With relaxed ordering, you can use a [materialized CTE](https://www.postgresql.o ```sql WITH relaxed_results AS MATERIALIZED ( SELECT id, embedding <-> '[1,2,3]' AS distance FROM items WHERE category_id = 123 ORDER BY distance LIMIT 5 -) SELECT * FROM relaxed_results ORDER BY distance; +) SELECT * FROM relaxed_results ORDER BY distance + 0; ``` For queries that filter by distance, use a materialized CTE and place the distance filter outside of it for best performance (due to the [current behavior](https://www.postgresql.org/message-id/flat/CAOdR5yGUoMQ6j7M5hNUXrySzaqZVGf_Ne%2B8fwZMRKTFxU1nbJg%40mail.gmail.com) of the Postgres executor) From a7c49d82834b675b92d5266f6e9ac9009df3d70c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 1 Jul 2025 11:13:29 -0700 Subject: [PATCH 31/85] Updated readme [skip ci] --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab8a06dd3..43c0430d2 100644 --- a/README.md +++ b/README.md @@ -495,6 +495,8 @@ WITH relaxed_results AS MATERIALIZED ( ) SELECT * FROM relaxed_results ORDER BY distance + 0; ``` +Note: `+ 0` is needed for Postgres 17+ + For queries that filter by distance, use a materialized CTE and place the distance filter outside of it for best performance (due to the [current behavior](https://www.postgresql.org/message-id/flat/CAOdR5yGUoMQ6j7M5hNUXrySzaqZVGf_Ne%2B8fwZMRKTFxU1nbJg%40mail.gmail.com) of the Postgres executor) ```sql From 742e2d1d284b2664a0ae5c2fcac18d1c527764c3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 9 Jul 2025 16:22:43 -0700 Subject: [PATCH 32/85] Synced .dockerignore with .gitignore [skip ci] --- .dockerignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.dockerignore b/.dockerignore index 6c60e6d5d..49dfd6c71 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,15 @@ /.git/ /dist/ +/log/ /results/ /tmp_check/ /sql/vector--?.?.?.sql regression.* *.o *.so +*.bc +*.dll +*.dylib +*.obj +*.lib +*.exp From 33ca8a61e23c887a129be66acaedfc76c6191cf2 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 9 Jul 2025 16:25:05 -0700 Subject: [PATCH 33/85] Added OS to Dockerfile [skip ci] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 936440928..840330258 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG PG_MAJOR=17 -FROM postgres:$PG_MAJOR +FROM postgres:$PG_MAJOR-bookworm ARG PG_MAJOR COPY . /tmp/pgvector From 44163d0a9787629e913313d8003ed3f983313e6f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 9 Jul 2025 22:01:34 -0700 Subject: [PATCH 34/85] Revert "Added OS to Dockerfile [skip ci]" This reverts commit 33ca8a61e23c887a129be66acaedfc76c6191cf2. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 840330258..936440928 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG PG_MAJOR=17 -FROM postgres:$PG_MAJOR-bookworm +FROM postgres:$PG_MAJOR ARG PG_MAJOR COPY . /tmp/pgvector From 665db75a3c265fb0086a7b72aed0d1dfa5e5bf7c Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 12:34:23 -0700 Subject: [PATCH 35/85] Updated Dockerfile to use release [skip ci] --- .dockerignore | 15 --------------- Dockerfile | 4 +++- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 49dfd6c71..000000000 --- a/.dockerignore +++ /dev/null @@ -1,15 +0,0 @@ -/.git/ -/dist/ -/log/ -/results/ -/tmp_check/ -/sql/vector--?.?.?.sql -regression.* -*.o -*.so -*.bc -*.dll -*.dylib -*.obj -*.lib -*.exp diff --git a/Dockerfile b/Dockerfile index 936440928..7cc81f02e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ +# syntax=docker/dockerfile:1 + ARG PG_MAJOR=17 FROM postgres:$PG_MAJOR ARG PG_MAJOR -COPY . /tmp/pgvector +ADD https://github.com/pgvector/pgvector.git#v0.8.0 /tmp/pgvector RUN apt-get update && \ apt-mark hold locales && \ From 3600ab93e59bfcc74efff73be07849ea5f2d161a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 13:14:29 -0700 Subject: [PATCH 36/85] Added Docker images with -bookworm suffix [skip ci] --- Dockerfile | 3 ++- Makefile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7cc81f02e..23682129e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ # syntax=docker/dockerfile:1 ARG PG_MAJOR=17 -FROM postgres:$PG_MAJOR +ARG DEBIAN_CODENAME=bookworm +FROM postgres:$PG_MAJOR-$DEBIAN_CODENAME ARG PG_MAJOR ADD https://github.com/pgvector/pgvector.git#v0.8.0 /tmp/pgvector diff --git a/Makefile b/Makefile index 7a4b88caf..6fdede0ba 100644 --- a/Makefile +++ b/Makefile @@ -76,4 +76,4 @@ docker: .PHONY: docker-release docker-release: - docker buildx build --push --pull --no-cache --platform linux/amd64,linux/arm64 --build-arg PG_MAJOR=$(PG_MAJOR) -t pgvector/pgvector:pg$(PG_MAJOR) -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR) . + docker buildx build --push --pull --no-cache --platform linux/amd64,linux/arm64 --build-arg PG_MAJOR=$(PG_MAJOR) --build-arg DEBIAN_CODENAME=bookworm -t pgvector/pgvector:pg$(PG_MAJOR) -t pgvector/pgvector:pg$(PG_MAJOR)-bookworm -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR) -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR)-bookworm . From 247c8dc8a556fe788a831d1bb327ec88c622133a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 13:25:51 -0700 Subject: [PATCH 37/85] Updated changelog [skip ci] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 757f998d0..27dcb50cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.1 (unreleased) + +- Added support for Postgres 18 + ## 0.8.0 (2024-10-30) - Added support for iterative index scans From 3be8693c13c71743433b441a1f6df79a1c9ef3c0 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 13:44:59 -0700 Subject: [PATCH 38/85] Added supported Docker tags to readme [skip ci] --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 43c0430d2..536c3d107 100644 --- a/README.md +++ b/README.md @@ -1143,6 +1143,14 @@ docker pull pgvector/pgvector:pg17 This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (replace `17` with your Postgres server version, and run it the same way). +Supported tags are: + +- `pg17`, `pg17-bookworm`, `0.8.0-pg17`, `0.8.0-pg17-bookworm` +- `pg16`, `pg16-bookworm`, `0.8.0-pg16`, `0.8.0-pg16-bookworm` +- `pg15`, `pg15-bookworm`, `0.8.0-pg15`, `0.8.0-pg15-bookworm` +- `pg14`, `pg14-bookworm`, `0.8.0-pg14`, `0.8.0-pg14-bookworm` +- `pg13`, `pg13-bookworm`, `0.8.0-pg13`, `0.8.0-pg13-bookworm` + You can also build the image manually: ```sh From 5b8b68ba1da86b1727989a89edfd1cb886932062 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 18:19:28 -0700 Subject: [PATCH 39/85] Use consistent style [skip ci] --- src/vector.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/vector.c b/src/vector.c index d2312e042..66db3d2f1 100644 --- a/src/vector.c +++ b/src/vector.c @@ -916,19 +916,17 @@ vector_concat(PG_FUNCTION_ARGS) Vector *b = PG_GETARG_VECTOR_P(1); Vector *result; int dim = a->dim + b->dim; - int dim_a = a->dim; - int dim_b = b->dim; CheckDim(dim); result = InitVector(dim); /* Auto-vectorized */ - for (int i = 0; i < dim_a; i++) + for (int i = 0, imax = a->dim; i < imax; i++) result->x[i] = a->x[i]; /* Auto-vectorized */ - for (int i = 0; i < dim_b; i++) - result->x[i + dim_a] = b->x[i]; + for (int i = 0, imax = b->dim, start = a->dim; i < imax; i++) + result->x[i + start] = b->x[i]; PG_RETURN_POINTER(result); } From 6ef7fccb5cd2ec89bb98692ea9c3507f9ac58c84 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 27 Jul 2025 19:50:46 -0700 Subject: [PATCH 40/85] Added Postgres 19 to CI [skip ci] --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a379e3682..f39786d01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,8 @@ jobs: fail-fast: false matrix: include: + - postgres: 19 + os: ubuntu-24.04 - postgres: 18 os: ubuntu-24.04 - postgres: 17 @@ -28,7 +30,7 @@ jobs: dev-files: true - run: make env: - PG_CFLAGS: ${{ matrix.postgres == 18 && '-Wno-missing-field-initializers' || '' }} -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare + PG_CFLAGS: ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }} -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare - run: | export PG_CONFIG=`which pg_config` sudo --preserve-env=PG_CONFIG make install From e29fc3aa1a7299b9126f31c43fccffca58d82d37 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 31 Jul 2025 19:59:27 -0700 Subject: [PATCH 41/85] Switched to PG_MODULE_MAGIC_EXT for Postgres 18+ [skip ci] --- src/vector.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vector.c b/src/vector.c index 66db3d2f1..256d632a6 100644 --- a/src/vector.c +++ b/src/vector.c @@ -35,7 +35,11 @@ #define VECTOR_TARGET_CLONES #endif +#if PG_VERSION_NUM >= 180000 +PG_MODULE_MAGIC_EXT(.name = "vector", .version = "0.8.0"); +#else PG_MODULE_MAGIC; +#endif /* * Initialize index options and variables From 26b50e536f66a3cb60acc2f0403bc15328690d54 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 9 Aug 2025 12:09:29 -0700 Subject: [PATCH 42/85] Updated FreeBSD package name in readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 536c3d107..9f2a930e3 100644 --- a/README.md +++ b/README.md @@ -1210,7 +1210,7 @@ Note: Replace `17` with your Postgres server version Install the FreeBSD package with: ```sh -pkg install postgresql16-pgvector +pkg install postgresql17-pgvector ``` or the port with: From 30382418dacb6b0d58522bbcd3c3caa18f07e1c9 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 19 Aug 2025 12:44:54 -0700 Subject: [PATCH 43/85] Ran pgindent [skip ci] --- src/vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector.c b/src/vector.c index 256d632a6..7da2bf30b 100644 --- a/src/vector.c +++ b/src/vector.c @@ -36,7 +36,7 @@ #endif #if PG_VERSION_NUM >= 180000 -PG_MODULE_MAGIC_EXT(.name = "vector", .version = "0.8.0"); +PG_MODULE_MAGIC_EXT(.name = "vector",.version = "0.8.0"); #else PG_MODULE_MAGIC; #endif From 0c9070ba82fb4e6b6997cdd76b88442175a2f8ab Mon Sep 17 00:00:00 2001 From: Luca Giacchino Date: Tue, 12 Aug 2025 19:52:49 -0700 Subject: [PATCH 44/85] Add autovectorized implementation of binary quantize --- src/vector.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vector.c b/src/vector.c index 7da2bf30b..4c1f695e6 100644 --- a/src/vector.c +++ b/src/vector.c @@ -946,8 +946,18 @@ binary_quantize(PG_FUNCTION_ARGS) float *ax = a->x; VarBit *result = InitBitVector(a->dim); unsigned char *rx = VARBITS(result); + int i; + int count = (a->dim / 8) * 8; + unsigned char result_byte; - for (int i = 0; i < a->dim; i++) + for (i = 0; i < count; i += 8) + { + result_byte = 0; + for (int j = 0; j < 8; j++) + result_byte |= (ax[i + j] > 0) << (7 - j); + rx[i / 8] = result_byte; + } + for (; i < a->dim; i++) rx[i / 8] |= (ax[i] > 0) << (7 - (i % 8)); PG_RETURN_VARBIT_P(result); From 6aec80ccdb19197796394095e4bbb3f8d6b1d314 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 19 Aug 2025 13:47:11 -0700 Subject: [PATCH 45/85] Improved performance of binary_quantize function for halfvec --- CHANGELOG.md | 1 + src/halfvec.c | 15 ++++++++++++++- src/vector.c | 11 +++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27dcb50cc..c85bcf03c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.8.1 (unreleased) - Added support for Postgres 18 +- Improved performance of `binary_quantize` function ## 0.8.0 (2024-10-30) diff --git a/src/halfvec.c b/src/halfvec.c index aad320b1c..e255b5327 100644 --- a/src/halfvec.c +++ b/src/halfvec.c @@ -898,8 +898,21 @@ halfvec_binary_quantize(PG_FUNCTION_ARGS) half *ax = a->x; VarBit *result = InitBitVector(a->dim); unsigned char *rx = VARBITS(result); + int i = 0; + int count = (a->dim / 8) * 8; - for (int i = 0; i < a->dim; i++) + /* Auto-vectorized */ + for (; i < count; i += 8) + { + unsigned char result_byte = 0; + + for (int j = 0; j < 8; j++) + result_byte |= (HalfToFloat4(ax[i + j]) > 0) << (7 - j); + + rx[i / 8] = result_byte; + } + + for (; i < a->dim; i++) rx[i / 8] |= (HalfToFloat4(ax[i]) > 0) << (7 - (i % 8)); PG_RETURN_VARBIT_P(result); diff --git a/src/vector.c b/src/vector.c index 4c1f695e6..0630cf811 100644 --- a/src/vector.c +++ b/src/vector.c @@ -946,17 +946,20 @@ binary_quantize(PG_FUNCTION_ARGS) float *ax = a->x; VarBit *result = InitBitVector(a->dim); unsigned char *rx = VARBITS(result); - int i; + int i = 0; int count = (a->dim / 8) * 8; - unsigned char result_byte; - for (i = 0; i < count; i += 8) + /* Auto-vectorized */ + for (; i < count; i += 8) { - result_byte = 0; + unsigned char result_byte = 0; + for (int j = 0; j < 8; j++) result_byte |= (ax[i + j] > 0) << (7 - j); + rx[i / 8] = result_byte; } + for (; i < a->dim; i++) rx[i / 8] |= (ax[i] > 0) << (7 - (i % 8)); From ea4746f6c0864cee7c400741c64c2651121c2aa8 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 19 Aug 2025 14:26:36 -0700 Subject: [PATCH 46/85] Updated comment [skip ci] --- src/halfvec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/halfvec.c b/src/halfvec.c index e255b5327..6b926e1ee 100644 --- a/src/halfvec.c +++ b/src/halfvec.c @@ -901,7 +901,7 @@ halfvec_binary_quantize(PG_FUNCTION_ARGS) int i = 0; int count = (a->dim / 8) * 8; - /* Auto-vectorized */ + /* Auto-vectorized on aarch64 */ for (; i < count; i += 8) { unsigned char result_byte = 0; From dd3a1e9137d8cd2877c9d5891e6d9928e3f59077 Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Sat, 23 Aug 2025 18:31:22 +0800 Subject: [PATCH 47/85] Use NIL for empty lists (#890) Postgres standard way to check for list emptiness is to compare a pointer to NIL rather than NULL. --- src/hnsw.c | 2 +- src/ivfflat.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index ec7c98852..6a6db507f 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -130,7 +130,7 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Relation index; /* Never use index without order */ - if (path->indexorderbys == NULL) + if (path->indexorderbys == NIL) { *indexStartupCost = get_float8_infinity(); *indexTotalCost = get_float8_infinity(); diff --git a/src/ivfflat.c b/src/ivfflat.c index 736d537d1..31c2f7d5e 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -92,7 +92,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Relation index; /* Never use index without order */ - if (path->indexorderbys == NULL) + if (path->indexorderbys == NIL) { *indexStartupCost = get_float8_infinity(); *indexTotalCost = get_float8_infinity(); From bbe66e821b6089ad7bc9e766c57018dd5197b8bf Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 23 Aug 2025 19:34:11 -0700 Subject: [PATCH 48/85] Added Docker images for Debian 13 / Trixie [skip ci] --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 6fdede0ba..8533c5b6e 100644 --- a/Makefile +++ b/Makefile @@ -77,3 +77,8 @@ docker: docker-release: docker buildx build --push --pull --no-cache --platform linux/amd64,linux/arm64 --build-arg PG_MAJOR=$(PG_MAJOR) --build-arg DEBIAN_CODENAME=bookworm -t pgvector/pgvector:pg$(PG_MAJOR) -t pgvector/pgvector:pg$(PG_MAJOR)-bookworm -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR) -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR)-bookworm . + +.PHONY: docker-release-trixie + +docker-release-trixie: + docker buildx build --push --pull --no-cache --platform linux/amd64,linux/arm64 --build-arg PG_MAJOR=$(PG_MAJOR) --build-arg DEBIAN_CODENAME=trixie -t pgvector/pgvector:pg$(PG_MAJOR)-trixie -t pgvector/pgvector:$(EXTVERSION)-pg$(PG_MAJOR)-trixie . From 6f46a1035d694caadd6cb25c2ce517d1f48dc4d6 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 23 Aug 2025 19:46:07 -0700 Subject: [PATCH 49/85] Added new Docker images to readme [skip ci] --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f2a930e3..851630d2f 100644 --- a/README.md +++ b/README.md @@ -1138,17 +1138,22 @@ If installation fails with `Access is denied`, re-run the installation instructi Get the [Docker image](https://hub.docker.com/r/pgvector/pgvector) with: ```sh -docker pull pgvector/pgvector:pg17 +docker pull pgvector/pgvector:pg17-trixie ``` This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (replace `17` with your Postgres server version, and run it the same way). Supported tags are: +- `pg17-trixie`, `0.8.0-pg17-trixie` - `pg17`, `pg17-bookworm`, `0.8.0-pg17`, `0.8.0-pg17-bookworm` +- `pg16-trixie`, `0.8.0-pg16-trixie` - `pg16`, `pg16-bookworm`, `0.8.0-pg16`, `0.8.0-pg16-bookworm` +- `pg15-trixie`, `0.8.0-pg15-trixie` - `pg15`, `pg15-bookworm`, `0.8.0-pg15`, `0.8.0-pg15-bookworm` +- `pg14-trixie`, `0.8.0-pg14-trixie` - `pg14`, `pg14-bookworm`, `0.8.0-pg14`, `0.8.0-pg14-bookworm` +- `pg13-trixie`, `0.8.0-pg13-trixie` - `pg13`, `pg13-bookworm`, `0.8.0-pg13`, `0.8.0-pg13-bookworm` You can also build the image manually: From c3ff955231366c6522a4eb5c116707cdd5d78d09 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 23 Aug 2025 19:57:14 -0700 Subject: [PATCH 50/85] Reordered supported Docker tags [skip ci] --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 851630d2f..b8259f4a6 100644 --- a/README.md +++ b/README.md @@ -1146,15 +1146,15 @@ This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (r Supported tags are: - `pg17-trixie`, `0.8.0-pg17-trixie` -- `pg17`, `pg17-bookworm`, `0.8.0-pg17`, `0.8.0-pg17-bookworm` +- `pg17-bookworm`, `0.8.0-pg17-bookworm`, `pg17`, `0.8.0-pg17` - `pg16-trixie`, `0.8.0-pg16-trixie` -- `pg16`, `pg16-bookworm`, `0.8.0-pg16`, `0.8.0-pg16-bookworm` +- `pg16-bookworm`, `0.8.0-pg16-bookworm`, `pg16`, `0.8.0-pg16` - `pg15-trixie`, `0.8.0-pg15-trixie` -- `pg15`, `pg15-bookworm`, `0.8.0-pg15`, `0.8.0-pg15-bookworm` +- `pg15-bookworm`, `0.8.0-pg15-bookworm`, `pg15`, `0.8.0-pg15` - `pg14-trixie`, `0.8.0-pg14-trixie` -- `pg14`, `pg14-bookworm`, `0.8.0-pg14`, `0.8.0-pg14-bookworm` +- `pg14-bookworm`, `0.8.0-pg14-bookworm`, `pg14`, `0.8.0-pg14` - `pg13-trixie`, `0.8.0-pg13-trixie` -- `pg13`, `pg13-bookworm`, `0.8.0-pg13`, `0.8.0-pg13-bookworm` +- `pg13-bookworm`, `0.8.0-pg13-bookworm`, `pg13`, `0.8.0-pg13` You can also build the image manually: From 67e648b13e59932f2f72a2b0f5d5e176fb85e200 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 29 Aug 2025 01:09:18 -0700 Subject: [PATCH 51/85] Added another test for binary_quantize function [skip ci] --- test/expected/halfvec.out | 6 ++++++ test/expected/vector_type.out | 6 ++++++ test/sql/halfvec.sql | 1 + test/sql/vector_type.sql | 1 + 4 files changed, 14 insertions(+) diff --git a/test/expected/halfvec.out b/test/expected/halfvec.out index a3ce8931f..3ef913d6c 100644 --- a/test/expected/halfvec.out +++ b/test/expected/halfvec.out @@ -540,6 +540,12 @@ SELECT binary_quantize('[0,0.1,-0.2,-0.3,0.4,0.5,0.6,-0.7,0.8,-0.9,1]'::halfvec) 01001110101 (1 row) +SELECT binary_quantize('[1,2,3,-4,5,6,-7,8,1,-2,-3,4,5,-6,7,8,-1,2,3]'::halfvec); + binary_quantize +--------------------- + 1110110110011011011 +(1 row) + SELECT subvector('[1,2,3,4,5]'::halfvec, 1, 3); subvector ----------- diff --git a/test/expected/vector_type.out b/test/expected/vector_type.out index 674865822..f4c85d035 100644 --- a/test/expected/vector_type.out +++ b/test/expected/vector_type.out @@ -576,6 +576,12 @@ SELECT binary_quantize('[0,0.1,-0.2,-0.3,0.4,0.5,0.6,-0.7,0.8,-0.9,1]'::vector); 01001110101 (1 row) +SELECT binary_quantize('[1,2,3,-4,5,6,-7,8,1,-2,-3,4,5,-6,7,8,-1,2,3]'::vector); + binary_quantize +--------------------- + 1110110110011011011 +(1 row) + SELECT subvector('[1,2,3,4,5]'::vector, 1, 3); subvector ----------- diff --git a/test/sql/halfvec.sql b/test/sql/halfvec.sql index 1a3fd1b82..592a6e38a 100644 --- a/test/sql/halfvec.sql +++ b/test/sql/halfvec.sql @@ -121,6 +121,7 @@ SELECT l2_normalize('[65504]'::halfvec); SELECT binary_quantize('[1,0,-1]'::halfvec); SELECT binary_quantize('[0,0.1,-0.2,-0.3,0.4,0.5,0.6,-0.7,0.8,-0.9,1]'::halfvec); +SELECT binary_quantize('[1,2,3,-4,5,6,-7,8,1,-2,-3,4,5,-6,7,8,-1,2,3]'::halfvec); SELECT subvector('[1,2,3,4,5]'::halfvec, 1, 3); SELECT subvector('[1,2,3,4,5]'::halfvec, 3, 2); diff --git a/test/sql/vector_type.sql b/test/sql/vector_type.sql index 088b040aa..086a39bcf 100644 --- a/test/sql/vector_type.sql +++ b/test/sql/vector_type.sql @@ -128,6 +128,7 @@ SELECT l2_normalize('[3e38]'::vector); SELECT binary_quantize('[1,0,-1]'::vector); SELECT binary_quantize('[0,0.1,-0.2,-0.3,0.4,0.5,0.6,-0.7,0.8,-0.9,1]'::vector); +SELECT binary_quantize('[1,2,3,-4,5,6,-7,8,1,-2,-3,4,5,-6,7,8,-1,2,3]'::vector); SELECT subvector('[1,2,3,4,5]'::vector, 1, 3); SELECT subvector('[1,2,3,4,5]'::vector, 3, 2); From 815f48e4899c747bfd4f882a418154943f3c4826 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 4 Sep 2025 15:36:18 -0700 Subject: [PATCH 52/85] Updated changelog [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c85bcf03c..4b2aed351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.8.1 (unreleased) -- Added support for Postgres 18 +- Added support for Postgres 18 rc1 - Improved performance of `binary_quantize` function ## 0.8.0 (2024-10-30) From 3f687687eea0e240fb19e700ec40df3742e99bd1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 4 Sep 2025 15:58:23 -0700 Subject: [PATCH 53/85] Fixed compilation error with Postgres 19 --- src/hnsw.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hnsw.c b/src/hnsw.c index 6a6db507f..1d56ef6ea 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -52,12 +52,20 @@ HnswInitLockTranche(void) sizeof(int) * 1, &found); if (!found) + { +#if PG_VERSION_NUM >= 190000 + tranche_ids[0] = LWLockNewTrancheId("HnswBuild"); +#else tranche_ids[0] = LWLockNewTrancheId(); +#endif + } hnsw_lock_tranche_id = tranche_ids[0]; LWLockRelease(AddinShmemInitLock); +#if PG_VERSION_NUM < 190000 /* Per-backend registration of the tranche ID */ LWLockRegisterTranche(hnsw_lock_tranche_id, "HnswBuild"); +#endif } /* From 778dacf20c07caf904557a88705142631818d8cb Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 4 Sep 2025 17:51:09 -0700 Subject: [PATCH 54/85] Version bump to 0.8.1 [skip ci] --- CHANGELOG.md | 2 +- Dockerfile | 2 +- META.json | 4 ++-- Makefile | 2 +- Makefile.win | 2 +- README.md | 26 +++++++++++++------------- sql/vector--0.8.0--0.8.1.sql | 2 ++ src/vector.c | 2 +- vector.control | 2 +- 9 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 sql/vector--0.8.0--0.8.1.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b2aed351..8618d1afd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.8.1 (unreleased) +## 0.8.1 (2025-09-04) - Added support for Postgres 18 rc1 - Improved performance of `binary_quantize` function diff --git a/Dockerfile b/Dockerfile index 23682129e..7e06759d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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.0 /tmp/pgvector +ADD https://github.com/pgvector/pgvector.git#v0.8.1 /tmp/pgvector RUN apt-get update && \ apt-mark hold locales && \ diff --git a/META.json b/META.json index b9a68f62a..343518d1c 100644 --- a/META.json +++ b/META.json @@ -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.0", + "version": "0.8.1", "maintainer": [ "Andrew Kane " ], @@ -20,7 +20,7 @@ "vector": { "file": "sql/vector.sql", "docfile": "README.md", - "version": "0.8.0", + "version": "0.8.1", "abstract": "Open-source vector similarity search for Postgres" } }, diff --git a/Makefile b/Makefile index 8533c5b6e..d98d73b8c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ EXTENSION = vector -EXTVERSION = 0.8.0 +EXTVERSION = 0.8.1 MODULE_big = vector DATA = $(wildcard sql/*--*--*.sql) diff --git a/Makefile.win b/Makefile.win index 8c62f9d5f..1fee4a683 100644 --- a/Makefile.win +++ b/Makefile.win @@ -1,5 +1,5 @@ EXTENSION = vector -EXTVERSION = 0.8.0 +EXTVERSION = 0.8.1 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 diff --git a/README.md b/README.md index b8259f4a6..dfd16ec64 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Compile and install the extension (supports Postgres 13+) ```sh cd /tmp -git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git +git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector make make install # may need sudo @@ -38,7 +38,7 @@ Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/buil ```cmd set "PGROOT=C:\Program Files\PostgreSQL\17" cd %TEMP% -git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git +git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector nmake /F Makefile.win nmake /F Makefile.win install @@ -1145,21 +1145,21 @@ This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (r Supported tags are: -- `pg17-trixie`, `0.8.0-pg17-trixie` -- `pg17-bookworm`, `0.8.0-pg17-bookworm`, `pg17`, `0.8.0-pg17` -- `pg16-trixie`, `0.8.0-pg16-trixie` -- `pg16-bookworm`, `0.8.0-pg16-bookworm`, `pg16`, `0.8.0-pg16` -- `pg15-trixie`, `0.8.0-pg15-trixie` -- `pg15-bookworm`, `0.8.0-pg15-bookworm`, `pg15`, `0.8.0-pg15` -- `pg14-trixie`, `0.8.0-pg14-trixie` -- `pg14-bookworm`, `0.8.0-pg14-bookworm`, `pg14`, `0.8.0-pg14` -- `pg13-trixie`, `0.8.0-pg13-trixie` -- `pg13-bookworm`, `0.8.0-pg13-bookworm`, `pg13`, `0.8.0-pg13` +- `pg17-trixie`, `0.8.1-pg17-trixie` +- `pg17-bookworm`, `0.8.1-pg17-bookworm`, `pg17`, `0.8.1-pg17` +- `pg16-trixie`, `0.8.1-pg16-trixie` +- `pg16-bookworm`, `0.8.1-pg16-bookworm`, `pg16`, `0.8.1-pg16` +- `pg15-trixie`, `0.8.1-pg15-trixie` +- `pg15-bookworm`, `0.8.1-pg15-bookworm`, `pg15`, `0.8.1-pg15` +- `pg14-trixie`, `0.8.1-pg14-trixie` +- `pg14-bookworm`, `0.8.1-pg14-bookworm`, `pg14`, `0.8.1-pg14` +- `pg13-trixie`, `0.8.1-pg13-trixie` +- `pg13-bookworm`, `0.8.1-pg13-bookworm`, `pg13`, `0.8.1-pg13` You can also build the image manually: ```sh -git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git +git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector docker build --pull --build-arg PG_MAJOR=17 -t myuser/pgvector . ``` diff --git a/sql/vector--0.8.0--0.8.1.sql b/sql/vector--0.8.0--0.8.1.sql new file mode 100644 index 000000000..547bd44a3 --- /dev/null +++ b/sql/vector--0.8.0--0.8.1.sql @@ -0,0 +1,2 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "ALTER EXTENSION vector UPDATE TO '0.8.1'" to load this file. \quit diff --git a/src/vector.c b/src/vector.c index 0630cf811..03f70d601 100644 --- a/src/vector.c +++ b/src/vector.c @@ -36,7 +36,7 @@ #endif #if PG_VERSION_NUM >= 180000 -PG_MODULE_MAGIC_EXT(.name = "vector",.version = "0.8.0"); +PG_MODULE_MAGIC_EXT(.name = "vector",.version = "0.8.1"); #else PG_MODULE_MAGIC; #endif diff --git a/vector.control b/vector.control index 7bfc0f1fa..2ad02286a 100644 --- a/vector.control +++ b/vector.control @@ -1,4 +1,4 @@ comment = 'vector data type and ivfflat and hnsw access methods' -default_version = '0.8.0' +default_version = '0.8.1' module_pathname = '$libdir/vector' relocatable = true From db3755a58feb1cceec41a4b7cf87b74803b0fa27 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 5 Sep 2025 16:41:22 -0700 Subject: [PATCH 55/85] Added windows-2025 to CI [skip ci] --- .github/workflows/build.yml | 14 +++++++++++--- Makefile.win | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f39786d01..5be4570c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,18 +81,26 @@ jobs: LLVM_VERSION: ${{ matrix.os == 'macos-15' && 18 || 15 }} PG_CFLAGS: -DUSE_ASSERT_CHECKING windows: - runs-on: windows-latest + runs-on: ${{ matrix.os }} if: ${{ !startsWith(github.ref_name, 'mac') }} + strategy: + fail-fast: false + matrix: + include: + - postgres: 17 + os: windows-2025 + - postgres: 14 + os: windows-2022 steps: - uses: actions/checkout@v4 - uses: ankane/setup-postgres@v1 with: - postgres-version: 14 + postgres-version: ${{ matrix.postgres }} - run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^ nmake /NOLOGO /F Makefile.win && ^ nmake /NOLOGO /F Makefile.win install && ^ - nmake /NOLOGO /F Makefile.win installcheck && ^ + nmake /NOLOGO /F Makefile.win installcheck ${{ matrix.postgres != 17 && 'PG_REGRESS=$(PGROOT)\bin\pg_regress' || '' }} && ^ nmake /NOLOGO /F Makefile.win clean && ^ nmake /NOLOGO /F Makefile.win uninstall shell: cmd diff --git a/Makefile.win b/Makefile.win index 1fee4a683..46ab3da64 100644 --- a/Makefile.win +++ b/Makefile.win @@ -31,6 +31,9 @@ LIBDIR = $(PGROOT)\lib PKGLIBDIR = $(PGROOT)\lib SHAREDIR = $(PGROOT)\share +# Use $(PGROOT)\bin\pg_regress for Postgres < 17 +PG_REGRESS = $(LIBDIR)\pgxs\src\test\regress\pg_regress + CFLAGS = /nologo /I"$(INCLUDEDIR_SERVER)\port\win32_msvc" /I"$(INCLUDEDIR_SERVER)\port\win32" /I"$(INCLUDEDIR_SERVER)" /I"$(INCLUDEDIR)" CFLAGS = $(CFLAGS) $(PG_CFLAGS) @@ -58,7 +61,7 @@ install: all for %f in ($(HEADERS)) do copy %f "$(INCLUDEDIR_SERVER)\extension\$(EXTENSION)" installcheck: - "$(BINDIR)\pg_regress" --bindir="$(BINDIR)" $(REGRESS_OPTS) $(REGRESS) + "$(PG_REGRESS)" --bindir="$(BINDIR)" $(REGRESS_OPTS) $(REGRESS) uninstall: del /f "$(PKGLIBDIR)\$(SHLIB)" From c205a12107a170180aadfee02a1e7c018d30c111 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 5 Sep 2025 17:03:37 -0700 Subject: [PATCH 56/85] Updated CI [skip ci] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5be4570c5..24ac07a00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: tar xf $TAG.tar.gz mv postgres-$TAG postgres env: - TAG: ${{ matrix.postgres == 17 && 'REL_17_2' || 'REL_14_15' }} + TAG: ${{ matrix.postgres == 17 && 'REL_17_6' || 'REL_14_19' }} - run: make prove_installcheck PROVE_FLAGS="-I ./postgres/src/test/perl -I ./test/perl" env: PERL5LIB: /Users/runner/perl5/lib/perl5 From 13c0dbf5304add283ef9167eba9794b92484197d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 19 Sep 2025 18:34:51 -0700 Subject: [PATCH 57/85] Test with macos-15-intel on CI [skip ci] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24ac07a00..42b4dd0a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: - postgres: 17 os: macos-15 - postgres: 14 - os: macos-13 + os: macos-15-intel steps: - uses: actions/checkout@v4 - uses: ankane/setup-postgres@v1 From 9e29dff78cf629e10757333d534dd5f3d0a53ec3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 19 Sep 2025 19:16:08 -0700 Subject: [PATCH 58/85] Updated CI [skip ci] --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 42b4dd0a9..ead56474b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: matrix: include: - postgres: 17 - os: macos-15 + os: macos-26 - postgres: 14 os: macos-15-intel steps: @@ -78,7 +78,7 @@ jobs: PERL5LIB: /Users/runner/perl5/lib/perl5 - run: make clean && $(brew --prefix llvm@$LLVM_VERSION)/bin/scan-build --status-bugs make env: - LLVM_VERSION: ${{ matrix.os == 'macos-15' && 18 || 15 }} + LLVM_VERSION: ${{ matrix.os == 'macos-26' && 20 || 18 }} PG_CFLAGS: -DUSE_ASSERT_CHECKING windows: runs-on: ${{ matrix.os }} From e7899b1250e11b9ffa94d93875d8157220ca3038 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 22 Sep 2025 11:55:01 -0700 Subject: [PATCH 59/85] Updated checkout action [skip ci] --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ead56474b..b749cf448 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - postgres: 13 os: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ankane/setup-postgres@v1 with: postgres-version: ${{ matrix.postgres }} @@ -53,7 +53,7 @@ jobs: - postgres: 14 os: macos-15-intel steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ankane/setup-postgres@v1 with: postgres-version: ${{ matrix.postgres }} @@ -92,7 +92,7 @@ jobs: - postgres: 14 os: windows-2022 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ankane/setup-postgres@v1 with: postgres-version: ${{ matrix.postgres }} @@ -133,7 +133,7 @@ jobs: if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ankane/setup-postgres-valgrind@v1 with: postgres-version: 17 From 02fefc0e3f7d6018f2b71af9bf434095cac31e4b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 25 Sep 2025 15:46:28 -0700 Subject: [PATCH 60/85] Updated readme for Postgres 18 [skip ci] --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index dfd16ec64..f6607151d 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#p Ensure [C++ support in Visual Studio](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) is installed and run `x64 Native Tools Command Prompt for VS [version]` as administrator. Then use `nmake` to build: ```cmd -set "PGROOT=C:\Program Files\PostgreSQL\17" +set "PGROOT=C:\Program Files\PostgreSQL\18" cd %TEMP% git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector @@ -1064,7 +1064,7 @@ l2_normalize(sparsevec) → sparsevec | Normalize with Euclidean norm | 0.7.0 If your machine has multiple Postgres installations, specify the path to [pg_config](https://www.postgresql.org/docs/current/app-pgconfig.html) with: ```sh -export PG_CONFIG=/Library/PostgreSQL/17/bin/pg_config +export PG_CONFIG=/Library/PostgreSQL/18/bin/pg_config ``` Then re-run the installation instructions (run `make clean` before `make` if needed). If `sudo` is needed for `make install`, use: @@ -1075,11 +1075,11 @@ sudo --preserve-env=PG_CONFIG make install A few common paths on Mac are: -- EDB installer - `/Library/PostgreSQL/17/bin/pg_config` -- Homebrew (arm64) - `/opt/homebrew/opt/postgresql@17/bin/pg_config` -- Homebrew (x86-64) - `/usr/local/opt/postgresql@17/bin/pg_config` +- EDB installer - `/Library/PostgreSQL/18/bin/pg_config` +- Homebrew (arm64) - `/opt/homebrew/opt/postgresql@18/bin/pg_config` +- Homebrew (x86-64) - `/usr/local/opt/postgresql@18/bin/pg_config` -Note: Replace `17` with your Postgres server version +Note: Replace `18` with your Postgres server version ### Missing Header @@ -1088,10 +1088,10 @@ If compilation fails with `fatal error: postgres.h: No such file or directory`, For Ubuntu and Debian, use: ```sh -sudo apt install postgresql-server-dev-17 +sudo apt install postgresql-server-dev-18 ``` -Note: Replace `17` with your Postgres server version +Note: Replace `18` with your Postgres server version ### Missing SDK @@ -1193,22 +1193,22 @@ pgxn install vector Debian and Ubuntu packages are available from the [PostgreSQL APT Repository](https://wiki.postgresql.org/wiki/Apt). Follow the [setup instructions](https://wiki.postgresql.org/wiki/Apt#Quickstart) and run: ```sh -sudo apt install postgresql-17-pgvector +sudo apt install postgresql-18-pgvector ``` -Note: Replace `17` with your Postgres server version +Note: Replace `18` with your Postgres server version ### Yum RPM packages are available from the [PostgreSQL Yum Repository](https://yum.postgresql.org/). Follow the [setup instructions](https://www.postgresql.org/download/linux/redhat/) for your distribution and run: ```sh -sudo yum install pgvector_17 +sudo yum install pgvector_18 # or -sudo dnf install pgvector_17 +sudo dnf install pgvector_18 ``` -Note: Replace `17` with your Postgres server version +Note: Replace `18` with your Postgres server version ### pkg From bc05dbf312095306e76cbdda0a239303daf542c4 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 25 Sep 2025 15:54:37 -0700 Subject: [PATCH 61/85] Updated CI for Postgres 18 [skip ci] --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b749cf448..b9e5aca1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: fail-fast: false matrix: include: - - postgres: 17 + - postgres: 18 os: macos-26 - postgres: 14 os: macos-15-intel @@ -59,7 +59,7 @@ jobs: postgres-version: ${{ matrix.postgres }} - run: make env: - PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-warning-option + PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-warning-option ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }} - run: make install - run: make installcheck - if: ${{ failure() }} @@ -72,7 +72,7 @@ jobs: tar xf $TAG.tar.gz mv postgres-$TAG postgres env: - TAG: ${{ matrix.postgres == 17 && 'REL_17_6' || 'REL_14_19' }} + TAG: ${{ matrix.postgres == 18 && 'REL_18_0' || 'REL_14_19' }} - run: make prove_installcheck PROVE_FLAGS="-I ./postgres/src/test/perl -I ./test/perl" env: PERL5LIB: /Users/runner/perl5/lib/perl5 @@ -136,7 +136,7 @@ jobs: - uses: actions/checkout@v5 - uses: ankane/setup-postgres-valgrind@v1 with: - postgres-version: 17 + postgres-version: 18 check-ub: yes - run: make OPTFLAGS="" - run: sudo --preserve-env=PG_CONFIG make install From 90add68d6f1270ffba27f3be77169d0ff3746200 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 25 Sep 2025 15:55:30 -0700 Subject: [PATCH 62/85] Updated style to be consistent with Mac [skip ci] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9e5aca1c..50e65a816 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: dev-files: true - run: make env: - PG_CFLAGS: ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }} -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare + PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }} - run: | export PG_CONFIG=`which pg_config` sudo --preserve-env=PG_CONFIG make install From 4cef9213ec81b8609bd06cb8ca02fee7c3c3f05d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 25 Sep 2025 20:00:10 -0700 Subject: [PATCH 63/85] Added Docker images for Postgres 18 [skip ci] --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f6607151d..85e98e09a 100644 --- a/README.md +++ b/README.md @@ -1138,13 +1138,15 @@ If installation fails with `Access is denied`, re-run the installation instructi Get the [Docker image](https://hub.docker.com/r/pgvector/pgvector) with: ```sh -docker pull pgvector/pgvector:pg17-trixie +docker pull pgvector/pgvector:pg18-trixie ``` -This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (replace `17` with your Postgres server version, and run it the same way). +This adds pgvector to the [Postgres image](https://hub.docker.com/_/postgres) (replace `18` with your Postgres server version, and run it the same way). Supported tags are: +- `pg18-trixie`, `0.8.1-pg18-trixie` +- `pg18-bookworm`, `0.8.1-pg18-bookworm`, `pg18`, `0.8.1-pg18` - `pg17-trixie`, `0.8.1-pg17-trixie` - `pg17-bookworm`, `0.8.1-pg17-bookworm`, `pg17`, `0.8.1-pg17` - `pg16-trixie`, `0.8.1-pg16-trixie` @@ -1161,7 +1163,7 @@ You can also build the image manually: ```sh git clone --branch v0.8.1 https://github.com/pgvector/pgvector.git cd pgvector -docker build --pull --build-arg PG_MAJOR=17 -t myuser/pgvector . +docker build --pull --build-arg PG_MAJOR=18 -t myuser/pgvector . ``` If you increase `maintenance_work_mem`, make sure `--shm-size` is at least that size to avoid an error with parallel HNSW index builds. From 1ff30720c7833a4c572364e7b2338b3f3ab4424e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 26 Sep 2025 13:02:37 -0700 Subject: [PATCH 64/85] Updated readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85e98e09a..b8d06279c 100644 --- a/README.md +++ b/README.md @@ -1180,7 +1180,7 @@ With Homebrew Postgres, you can use: brew install pgvector ``` -Note: This only adds it to the `postgresql@17` and `postgresql@14` formulas +Note: This only adds it to the `postgresql@18` and `postgresql@17` formulas ### PGXN From 8f4aa0751c3025d2b631adf56c7bdd5c0919a2b9 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 27 Sep 2025 15:51:32 -0700 Subject: [PATCH 65/85] Removed unused parameters [skip ci] --- src/hnswbuild.c | 8 ++++---- src/hnswinsert.c | 4 ++-- src/ivfbuild.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hnswbuild.c b/src/hnswbuild.c index b667478b6..08d8d5641 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -398,7 +398,7 @@ UpdateNeighborsInMemory(char *base, HnswSupport * support, HnswElement e, int m) * Update graph in memory */ static void -UpdateGraphInMemory(HnswSupport * support, HnswElement element, int m, int efConstruction, HnswElement entryPoint, HnswBuildState * buildstate) +UpdateGraphInMemory(HnswSupport * support, HnswElement element, int m, HnswElement entryPoint, HnswBuildState * buildstate) { HnswGraph *graph = buildstate->graph; char *base = buildstate->hnswarea; @@ -460,7 +460,7 @@ InsertTupleInMemory(HnswBuildState * buildstate, HnswElement element) HnswFindElementNeighbors(base, element, entryPoint, NULL, support, m, efConstruction, false); /* Update graph in memory */ - UpdateGraphInMemory(support, element, m, efConstruction, entryPoint, buildstate); + UpdateGraphInMemory(support, element, m, entryPoint, buildstate); /* Release entry lock */ LWLockRelease(entryLock); @@ -1054,7 +1054,7 @@ ComputeParallelWorkers(Relation heap, Relation index) * Build graph */ static void -BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum) +BuildGraph(HnswBuildState * buildstate) { int parallel_workers = 0; @@ -1102,7 +1102,7 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, InitBuildState(buildstate, heap, index, indexInfo, forkNum); - BuildGraph(buildstate, forkNum); + BuildGraph(buildstate); if (RelationNeedsWAL(index) || forkNum == INIT_FORKNUM) log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocksInFork(index, forkNum), true); diff --git a/src/hnswinsert.c b/src/hnswinsert.c index a5fac4eda..8adfaff01 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -660,7 +660,7 @@ FindDuplicateOnDisk(Relation index, HnswElement element, bool building) * Update graph on disk */ static void -UpdateGraphOnDisk(Relation index, HnswSupport * support, HnswElement element, int m, int efConstruction, HnswElement entryPoint, bool building) +UpdateGraphOnDisk(Relation index, HnswSupport * support, HnswElement element, int m, HnswElement entryPoint, bool building) { BlockNumber newInsertPage = InvalidBlockNumber; @@ -728,7 +728,7 @@ HnswInsertTupleOnDisk(Relation index, HnswSupport * support, Datum value, ItemPo HnswFindElementNeighbors(base, element, entryPoint, index, support, m, efConstruction, false); /* Update graph on disk */ - UpdateGraphOnDisk(index, support, element, m, efConstruction, entryPoint, building); + UpdateGraphOnDisk(index, support, element, m, entryPoint, building); /* Release lock */ UnlockPage(index, HNSW_UPDATE_LOCK, lockmode); diff --git a/src/ivfbuild.c b/src/ivfbuild.c index c51f40884..80433d832 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -138,7 +138,7 @@ SampleRows(IvfflatBuildState * buildstate) * Add tuple to sort */ static void -AddTupleToSort(Relation index, ItemPointer tid, Datum *values, IvfflatBuildState * buildstate) +AddTupleToSort(ItemPointer tid, Datum *values, IvfflatBuildState * buildstate) { double distance; double minDistance = DBL_MAX; @@ -215,7 +215,7 @@ BuildCallback(Relation index, ItemPointer tid, Datum *values, oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx); /* Add tuple to sort */ - AddTupleToSort(index, tid, values, buildstate); + AddTupleToSort(tid, values, buildstate); /* Reset memory context */ MemoryContextSwitchTo(oldCtx); @@ -470,8 +470,8 @@ CreateMetaPage(Relation index, int dimensions, int lists, ForkNumber forkNum) * Create list pages */ static void -CreateListPages(Relation index, VectorArray centers, int dimensions, - int lists, ForkNumber forkNum, ListInfo * *listInfo) +CreateListPages(Relation index, VectorArray centers, int lists, + ForkNumber forkNum, ListInfo * *listInfo) { Buffer buf; Page page; @@ -1004,7 +1004,7 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, /* Create pages */ CreateMetaPage(index, buildstate->dimensions, buildstate->lists, forkNum); - CreateListPages(index, buildstate->centers, buildstate->dimensions, buildstate->lists, forkNum, &buildstate->listInfo); + CreateListPages(index, buildstate->centers, buildstate->lists, forkNum, &buildstate->listInfo); CreateEntryPages(buildstate, forkNum); /* Write WAL for initialization fork since GenericXLog functions do not */ From d823c44591798ba3b13c34e60657bc1a8999e44b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 27 Sep 2025 15:58:18 -0700 Subject: [PATCH 66/85] Removed unused parameter [skip ci] --- src/ivfinsert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ivfinsert.c b/src/ivfinsert.c index 014c9be82..ebc61e49d 100644 --- a/src/ivfinsert.c +++ b/src/ivfinsert.c @@ -65,7 +65,7 @@ FindInsertPage(Relation index, Datum *values, BlockNumber *insertPage, ListInfo * Insert a tuple into the index */ static void -InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heap_tid, Relation heapRel) +InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heap_tid) { const IvfflatTypeInfo *typeInfo = IvfflatGetTypeInfo(index); IndexTuple itup; @@ -204,7 +204,7 @@ ivfflatinsert(Relation index, Datum *values, bool *isnull, ItemPointer heap_tid, oldCtx = MemoryContextSwitchTo(insertCtx); /* Insert tuple */ - InsertTuple(index, values, isnull, heap_tid, heap); + InsertTuple(index, values, isnull, heap_tid); /* Delete memory context */ MemoryContextSwitchTo(oldCtx); From 727d4836d2feb99f3f45116e5a2978803a207878 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 22 Oct 2025 11:47:11 -0700 Subject: [PATCH 67/85] Fixed Index Searches in EXPLAIN output for Postgres 18 --- CHANGELOG.md | 4 ++++ src/hnswscan.c | 4 ++++ src/ivfscan.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8618d1afd..a3515593f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.2 (unreleased) + +- Fixed `Index Searches` in `EXPLAIN` output for Postgres 18 + ## 0.8.1 (2025-09-04) - Added support for Postgres 18 rc1 diff --git a/src/hnswscan.c b/src/hnswscan.c index 955998a52..5c526f4a6 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -193,6 +193,10 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir) /* Count index scan for stats */ pgstat_count_index_scan(scan->indexRelation); +#if PG_VERSION_NUM >= 180000 + if (scan->instrument) + scan->instrument->nsearches++; +#endif /* Safety check */ if (scan->orderByData == NULL) diff --git a/src/ivfscan.c b/src/ivfscan.c index 6cc5d2efd..b42ada15d 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -355,6 +355,10 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir) /* Count index scan for stats */ pgstat_count_index_scan(scan->indexRelation); +#if PG_VERSION_NUM >= 180000 + if (scan->instrument) + scan->instrument->nsearches++; +#endif /* Safety check */ if (scan->orderByData == NULL) From 3ebb9a506efe8fcd643151bf77bfb2229b5ca239 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 22 Oct 2025 11:56:05 -0700 Subject: [PATCH 68/85] Added varatt headers for Postgres 16+ --- src/hnswbuild.c | 4 ++++ src/hnswinsert.c | 4 ++++ src/hnswutils.c | 4 ++++ src/hnswvacuum.c | 4 ++++ src/ivfbuild.c | 4 ++++ src/ivfflat.h | 4 ++++ src/ivfkmeans.c | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 08d8d5641..03f0ef4a4 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -54,6 +54,10 @@ #include "utils/datum.h" #include "utils/memutils.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #if PG_VERSION_NUM >= 140000 #include "utils/backend_progress.h" #else diff --git a/src/hnswinsert.c b/src/hnswinsert.c index 8adfaff01..a4d288506 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -9,6 +9,10 @@ #include "utils/datum.h" #include "utils/memutils.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + /* * Get the insert page */ diff --git a/src/hnswutils.c b/src/hnswutils.c index c52d2c78a..8e2a42c1d 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -15,6 +15,10 @@ #include "utils/memdebug.h" #include "utils/rel.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #if PG_VERSION_NUM < 170000 static inline uint64 murmurhash64(uint64 data) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 2f7b2f372..3a8ee26c0 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -9,6 +9,10 @@ #include "storage/lmgr.h" #include "utils/memutils.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #if PG_VERSION_NUM >= 180000 #define vacuum_delay_point() vacuum_delay_point(false) #endif diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 80433d832..7166b7da3 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -20,6 +20,10 @@ #include "utils/memutils.h" #include "vector.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #if PG_VERSION_NUM >= 140000 #include "utils/backend_progress.h" #else diff --git a/src/ivfflat.h b/src/ivfflat.h index 76608f334..c4e64e1dc 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -13,6 +13,10 @@ #include "utils/tuplesort.h" #include "vector.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #if PG_VERSION_NUM >= 150000 #include "common/pg_prng.h" #endif diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 4b6d14f1a..9c79e64ad 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -13,6 +13,10 @@ #include "utils/memutils.h" #include "vector.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + /* * Initialize with kmeans++ * From 2ee3113417a0901138ec9fcd6f50a05d351bbd75 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 22 Oct 2025 13:10:58 -0700 Subject: [PATCH 69/85] Updated readme [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8d06279c..0f7ee7a51 100644 --- a/README.md +++ b/README.md @@ -812,7 +812,7 @@ Yes, pgvector uses the write-ahead log (WAL), which allows for replication and p #### What if I want to index vectors with more than 2,000 dimensions? -You can use [half-precision indexing](#half-precision-indexing) to index up to 4,000 dimensions or [binary quantization](#binary-quantization) to index up to 64,000 dimensions. Another option is [dimensionality reduction](https://en.wikipedia.org/wiki/Dimensionality_reduction). +You can use [half-precision vectors](#half-precision-vectors) or [half-precision indexing](#half-precision-indexing) to index up to 4,000 dimensions or [binary quantization](#binary-quantization) to index up to 64,000 dimensions. Other options are [indexing subvectors](#indexing-subvectors) (for models that support it) or [dimensionality reduction](https://en.wikipedia.org/wiki/Dimensionality_reduction). #### Can I store vectors with different dimensions in the same column? From a24125839a5d9bbc77a514d64cf6ef1af867ccdf Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 28 Oct 2025 10:25:34 -0700 Subject: [PATCH 70/85] Updated readme [skip ci] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f7ee7a51..3c744464e 100644 --- a/README.md +++ b/README.md @@ -695,10 +695,10 @@ CREATE INDEX CONCURRENTLY ... ### Querying -Use `EXPLAIN ANALYZE` to debug performance. +Use `EXPLAIN (ANALYZE, BUFFERS)` to debug performance. ```sql -EXPLAIN ANALYZE SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5; +EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5; ``` #### Exact Search From 8dd37d4fb275f305ff2c9a645acb3fa64cdfaa30 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 Oct 2025 11:03:59 -0700 Subject: [PATCH 71/85] Improved install target for Windows - #917 [skip ci] --- Makefile.win | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.win b/Makefile.win index 46ab3da64..9d4cbe842 100644 --- a/Makefile.win +++ b/Makefile.win @@ -57,7 +57,7 @@ install: all copy $(SHLIB) "$(PKGLIBDIR)" copy $(EXTENSION).control "$(SHAREDIR)\extension" copy sql\$(EXTENSION)--*.sql "$(SHAREDIR)\extension" - mkdir "$(INCLUDEDIR_SERVER)\extension\$(EXTENSION)" + if not exist "$(INCLUDEDIR_SERVER)\extension\$(EXTENSION)" mkdir "$(INCLUDEDIR_SERVER)\extension\$(EXTENSION)" for %f in ($(HEADERS)) do copy %f "$(INCLUDEDIR_SERVER)\extension\$(EXTENSION)" installcheck: From 69e78e36a3a2735e451384db5f125736e65dea6f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 Oct 2025 11:40:29 -0700 Subject: [PATCH 72/85] Added link to pgvetor-pascal [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3c744464e..07acb7dee 100644 --- a/README.md +++ b/README.md @@ -790,6 +790,7 @@ Lisp | [pgvector-lisp](https://github.com/pgvector/pgvector-lisp) Lua | [pgvector-lua](https://github.com/pgvector/pgvector-lua) Nim | [pgvector-nim](https://github.com/pgvector/pgvector-nim) OCaml | [pgvector-ocaml](https://github.com/pgvector/pgvector-ocaml) +Pascal | [pgvector-pascal](https://github.com/pgvector/pgvector-pascal) Perl | [pgvector-perl](https://github.com/pgvector/pgvector-perl) PHP | [pgvector-php](https://github.com/pgvector/pgvector-php) Python | [pgvector-python](https://github.com/pgvector/pgvector-python) From 744362305bb576d3e0f6de2cf5ac5da590f1ce11 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 Oct 2025 11:48:44 -0700 Subject: [PATCH 73/85] Updated changelog [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3515593f..8f74ea89f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.8.2 (unreleased) +- Improved `install` target on Windows - Fixed `Index Searches` in `EXPLAIN` output for Postgres 18 ## 0.8.1 (2025-09-04) From a126c02184326287f8024bfce4c43d4e2fa099aa Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 30 Oct 2025 22:29:36 -0700 Subject: [PATCH 74/85] Added link to pgvector-ada [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 07acb7dee..90abd5dec 100644 --- a/README.md +++ b/README.md @@ -771,6 +771,7 @@ Use pgvector from any language with a Postgres client. You can even generate and Language | Libraries / Examples --- | --- +Ada | [pgvector-ada](https://github.com/pgvector/pgvector-ada) C | [pgvector-c](https://github.com/pgvector/pgvector-c) C++ | [pgvector-cpp](https://github.com/pgvector/pgvector-cpp) C#, F#, Visual Basic | [pgvector-dotnet](https://github.com/pgvector/pgvector-dotnet) From 2b742576b4b1b5a3ab6ac3aa0015492712d18bcd Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 24 Nov 2025 12:41:30 -0800 Subject: [PATCH 75/85] Added links [skip ci] --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 90abd5dec..d9cf188e8 100644 --- a/README.md +++ b/README.md @@ -772,6 +772,7 @@ Use pgvector from any language with a Postgres client. You can even generate and Language | Libraries / Examples --- | --- Ada | [pgvector-ada](https://github.com/pgvector/pgvector-ada) +Algol | [pgvector-algol](https://github.com/pgvector/pgvector-algol) C | [pgvector-c](https://github.com/pgvector/pgvector-c) C++ | [pgvector-cpp](https://github.com/pgvector/pgvector-cpp) C#, F#, Visual Basic | [pgvector-dotnet](https://github.com/pgvector/pgvector-dotnet) @@ -794,8 +795,10 @@ OCaml | [pgvector-ocaml](https://github.com/pgvector/pgvector-ocaml) Pascal | [pgvector-pascal](https://github.com/pgvector/pgvector-pascal) Perl | [pgvector-perl](https://github.com/pgvector/pgvector-perl) PHP | [pgvector-php](https://github.com/pgvector/pgvector-php) +Prolog | [pgvector-prolog](https://github.com/pgvector/pgvector-prolog) Python | [pgvector-python](https://github.com/pgvector/pgvector-python) R | [pgvector-r](https://github.com/pgvector/pgvector-r) +Racket | [pgvector-racket](https://github.com/pgvector/pgvector-racket) Raku | [pgvector-raku](https://github.com/pgvector/pgvector-raku) Ruby | [pgvector-ruby](https://github.com/pgvector/pgvector-ruby), [Neighbor](https://github.com/ankane/neighbor) Rust | [pgvector-rust](https://github.com/pgvector/pgvector-rust) From b7c0085afe3130acf309a9c4a3e150f1955bda2a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 1 Dec 2025 22:52:23 -0800 Subject: [PATCH 76/85] Added instructions for APK [skip ci] --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d9cf188e8..a1085204f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ make install # may need sudo See the [installation notes](#installation-notes---linux-and-mac) if you run into issues -You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#pgxn), [APT](#apt), [Yum](#yum), [pkg](#pkg), or [conda-forge](#conda-forge), and it comes preinstalled with [Postgres.app](#postgresapp) and many [hosted providers](#hosted-postgres). There are also instructions for [GitHub Actions](https://github.com/pgvector/setup-pgvector). +You can also install it with [Docker](#docker), [Homebrew](#homebrew), [PGXN](#pgxn), [APT](#apt), [Yum](#yum), [pkg](#pkg), [APK](#apk), or [conda-forge](#conda-forge), and it comes preinstalled with [Postgres.app](#postgresapp) and many [hosted providers](#hosted-postgres). There are also instructions for [GitHub Actions](https://github.com/pgvector/setup-pgvector). ### Windows @@ -1232,6 +1232,14 @@ cd /usr/ports/databases/pgvector make install ``` +### APK + +Install the Alpine package with: + +```sh +apk add postgresql-pgvector +``` + ### conda-forge With Conda Postgres, install from [conda-forge](https://anaconda.org/conda-forge/pgvector) with: From d72ee71f2367cf21b0434c33ff05c0d4c89802d1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 10 Dec 2025 14:59:29 -0800 Subject: [PATCH 77/85] Fixed compilation errors with Postgres 19 --- src/hnsw.h | 4 ++++ src/hnswbuild.c | 2 +- src/hnswinsert.c | 2 +- src/hnswutils.c | 6 +++--- src/ivfflat.h | 4 ++++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/hnsw.h b/src/hnsw.h index 5102bfb5a..a192a0289 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -12,6 +12,10 @@ #include "utils/sampling.h" #include "vector.h" +#if PG_VERSION_NUM >= 190000 +typedef Pointer Item; +#endif + #define HNSW_MAX_DIM 2000 #define HNSW_MAX_NNZ 1000 diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 03f0ef4a4..939f48f71 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -549,7 +549,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn /* Copy the datum */ memcpy(valuePtr, DatumGetPointer(value), valueSize); - HnswPtrStore(base, element->value, valuePtr); + HnswPtrStore(base, element->value, (char *) valuePtr); /* Create a lock for the element */ LWLockInitialize(&element->lock, hnsw_lock_tranche_id); diff --git a/src/hnswinsert.c b/src/hnswinsert.c index a4d288506..ddcead0c4 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -712,7 +712,7 @@ HnswInsertTupleOnDisk(Relation index, HnswSupport * support, Datum value, ItemPo /* Create an element */ element = HnswInitElement(base, heaptid, m, HnswGetMl(m), HnswGetMaxLevel(m), NULL); - HnswPtrStore(base, element->value, DatumGetPointer(value)); + HnswPtrStore(base, element->value, (char *) DatumGetPointer(value)); /* Prevent concurrent inserts when likely updating entry point */ if (entryPoint == NULL || element->level > entryPoint->level) diff --git a/src/hnswutils.c b/src/hnswutils.c index 8e2a42c1d..13ecb9d9b 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -260,7 +260,7 @@ HnswInitElement(char *base, ItemPointer heaptid, int m, double ml, int maxLevel, HnswInitNeighbors(base, element, m, allocator); - HnswPtrStore(base, element->value, (Pointer) NULL); + HnswPtrStore(base, element->value, (char *) NULL); return element; } @@ -286,7 +286,7 @@ HnswInitElementFromBlock(BlockNumber blkno, OffsetNumber offno) element->blkno = blkno; element->offno = offno; HnswPtrStore(base, element->neighbors, (HnswNeighborArrayPtr *) NULL); - HnswPtrStore(base, element->value, (Pointer) NULL); + HnswPtrStore(base, element->value, (char *) NULL); return element; } @@ -512,7 +512,7 @@ HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHe char *base = NULL; Datum value = datumCopy(PointerGetDatum(&etup->data), false, -1); - HnswPtrStore(base, element->value, DatumGetPointer(value)); + HnswPtrStore(base, element->value, (char *) DatumGetPointer(value)); } } diff --git a/src/ivfflat.h b/src/ivfflat.h index c4e64e1dc..0d9601e03 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -25,6 +25,10 @@ #include "portability/instr_time.h" #endif +#if PG_VERSION_NUM >= 190000 +typedef Pointer Item; +#endif + #define IVFFLAT_MAX_DIM 2000 /* Support functions */ From 5c25f81789bcb0220d73717086c6289ee5c84198 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 10 Dec 2025 18:49:00 -0800 Subject: [PATCH 78/85] Fixed inconsistent parameter names [skip ci] --- src/hnsw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hnsw.h b/src/hnsw.h index a192a0289..16c7f0db5 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -428,7 +428,7 @@ void *HnswAlloc(HnswAllocator * allocator, Size size); HnswElement HnswInitElement(char *base, ItemPointer tid, int m, double ml, int maxLevel, HnswAllocator * alloc); HnswElement HnswInitElementFromBlock(BlockNumber blkno, OffsetNumber offno); void HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint, Relation index, HnswSupport * support, int m, int efConstruction, bool existing); -HnswSearchCandidate *HnswEntryCandidate(char *base, HnswElement em, HnswQuery * q, Relation rel, HnswSupport * support, bool loadVec); +HnswSearchCandidate *HnswEntryCandidate(char *base, HnswElement entryPoint, HnswQuery * q, Relation index, HnswSupport * support, bool loadVec); void HnswUpdateMetaPage(Relation index, int updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum, bool building); void HnswSetNeighborTuple(char *base, HnswNeighborTuple ntup, HnswElement e, int m); void HnswAddHeapTid(HnswElement element, ItemPointer heaptid); From f85a7d3fd0743fcca46d60aa18a331e4b24ab0c8 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 10 Dec 2025 20:03:26 -0800 Subject: [PATCH 79/85] Keep clang-tidy happy [skip ci] --- src/hnswvacuum.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 3a8ee26c0..1469874d0 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -178,7 +178,12 @@ NeedsUpdated(HnswVacuumState * vacuumstate, HnswElement element) /* Also update if layer 0 is not full */ /* This could indicate too many candidates being deleted during insert */ if (!needsUpdated) + { + /* Keep clang-tidy happy */ + Assert(ntup->count > 0); + needsUpdated = !ItemPointerIsValid(&ntup->indextids[ntup->count - 1]); + } UnlockReleaseBuffer(buf); @@ -528,8 +533,9 @@ MarkDeleted(HnswVacuumState * vacuumstate) ntup = (HnswNeighborTuple) PageGetItem(npage, PageGetItemId(npage, neighborOffno)); /* Overwrite element */ + /* Use memset instead of MemSet to keep clang-tidy happy */ etup->deleted = 1; - MemSet(&etup->data, 0, VARSIZE_ANY(&etup->data)); + memset(&etup->data, 0, VARSIZE_ANY(&etup->data)); /* Overwrite neighbors */ for (int i = 0; i < ntup->count; i++) From 2b741ef06876b6bdb8d48ce23eeee118edcf0c3d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 00:35:18 -0800 Subject: [PATCH 80/85] Improved includes for types --- src/bitvec.c | 1 + src/halfutils.c | 2 ++ src/halfvec.c | 8 ++++++-- src/sparsevec.c | 7 ++++++- src/vector.c | 4 ++-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/bitvec.c b/src/bitvec.c index 094ddd282..8bdff956b 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -2,6 +2,7 @@ #include "bitutils.h" #include "bitvec.h" +#include "fmgr.h" #include "utils/varbit.h" #include "vector.h" diff --git a/src/halfutils.c b/src/halfutils.c index d16909409..2df4995c0 100644 --- a/src/halfutils.c +++ b/src/halfutils.c @@ -1,5 +1,7 @@ #include "postgres.h" +#include + #include "halfutils.h" #include "halfvec.h" diff --git a/src/halfvec.c b/src/halfvec.c index 6b926e1ee..6854c3d71 100644 --- a/src/halfvec.c +++ b/src/halfvec.c @@ -13,12 +13,16 @@ #include "port.h" /* for strtof() */ #include "sparsevec.h" #include "utils/array.h" -#include "utils/builtins.h" #include "utils/float.h" +#include "utils/fmgrprotos.h" #include "utils/lsyscache.h" -#include "utils/numeric.h" +#include "utils/varbit.h" #include "vector.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + #define STATE_DIMS(x) (ARR_DIMS(x)[0] - 1) #define CreateStateDatums(dim) palloc(sizeof(Datum) * (dim + 1)) diff --git a/src/sparsevec.c b/src/sparsevec.c index 1893752d8..ca1648f2a 100644 --- a/src/sparsevec.c +++ b/src/sparsevec.c @@ -5,18 +5,23 @@ #include "catalog/pg_type.h" #include "common/shortest_dec.h" -#include "common/string.h" #include "fmgr.h" #include "halfutils.h" #include "halfvec.h" +#include "lib/stringinfo.h" #include "libpq/pqformat.h" #include "sparsevec.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/float.h" +#include "utils/fmgrprotos.h" #include "utils/lsyscache.h" #include "vector.h" +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif + typedef struct SparseInputElement { int32 index; diff --git a/src/vector.c b/src/vector.c index 03f70d601..473683801 100644 --- a/src/vector.c +++ b/src/vector.c @@ -16,10 +16,10 @@ #include "port.h" /* for strtof() */ #include "sparsevec.h" #include "utils/array.h" -#include "utils/builtins.h" #include "utils/float.h" +#include "utils/fmgrprotos.h" #include "utils/lsyscache.h" -#include "utils/numeric.h" +#include "utils/varbit.h" #include "vector.h" #if PG_VERSION_NUM >= 160000 From 3975e212cc4cf1eec416b5f21d221f087e652c95 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 13:26:36 -0800 Subject: [PATCH 81/85] Improved includes for ivfkmeans [skip ci] --- src/ivfkmeans.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 9c79e64ad..293922807 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -1,17 +1,15 @@ #include "postgres.h" #include +#include #include -#include "bitvec.h" -#include "halfutils.h" -#include "halfvec.h" +#include "access/genam.h" +#include "fmgr.h" #include "ivfflat.h" #include "miscadmin.h" -#include "utils/builtins.h" -#include "utils/datum.h" #include "utils/memutils.h" -#include "vector.h" +#include "utils/relcache.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" From c711da411c4584260ad0b05865a58096e096c022 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 15:35:37 -0800 Subject: [PATCH 82/85] Improved includes for indexes --- src/hnsw.c | 6 ++++++ src/hnsw.h | 2 ++ src/hnswbuild.c | 8 ++++++-- src/hnswinsert.c | 5 +++-- src/hnswscan.c | 11 ++++++++++- src/hnswutils.c | 6 ++++-- src/hnswvacuum.c | 5 +++-- src/ivfbuild.c | 15 ++++++++++++--- src/ivfflat.c | 5 +++++ src/ivfinsert.c | 5 +++++ src/ivfscan.c | 11 +++++++++++ src/ivfutils.c | 10 ++++++++-- src/ivfvacuum.c | 3 +++ 13 files changed, 78 insertions(+), 14 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index 1d56ef6ea..891d0701e 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -1,18 +1,24 @@ #include "postgres.h" #include +#include #include #include "access/amapi.h" +#include "access/genam.h" #include "access/reloptions.h" #include "commands/progress.h" #include "commands/vacuum.h" +#include "fmgr.h" #include "hnsw.h" #include "miscadmin.h" +#include "nodes/pg_list.h" #include "utils/float.h" #include "utils/guc.h" +#include "utils/relcache.h" #include "utils/selfuncs.h" #include "utils/spccache.h" +#include "vector.h" #if PG_VERSION_NUM < 150000 #define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x) diff --git a/src/hnsw.h b/src/hnsw.h index 16c7f0db5..841af0fa7 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -3,6 +3,8 @@ #include "postgres.h" +#include + #include "access/genam.h" #include "access/parallel.h" #include "lib/pairingheap.h" diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 939f48f71..a32bf8f24 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -36,11 +36,12 @@ */ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/parallel.h" +#include "access/relscan.h" #include "access/table.h" #include "access/tableam.h" +#include "access/tupdesc.h" #include "access/xact.h" #include "access/xloginsert.h" #include "catalog/index.h" @@ -48,11 +49,14 @@ #include "commands/progress.h" #include "hnsw.h" #include "miscadmin.h" +#include "nodes/execnodes.h" #include "optimizer/optimizer.h" #include "storage/bufmgr.h" #include "tcop/tcopprot.h" #include "utils/datum.h" #include "utils/memutils.h" +#include "utils/rel.h" +#include "utils/snapmgr.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswinsert.c b/src/hnswinsert.c index ddcead0c4..8bd4d24ef 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -1,13 +1,14 @@ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/generic_xlog.h" #include "hnsw.h" +#include "nodes/execnodes.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/datum.h" #include "utils/memutils.h" +#include "utils/rel.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswscan.c b/src/hnswscan.c index 5c526f4a6..61a8d63e8 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -1,12 +1,21 @@ #include "postgres.h" +#include "access/genam.h" #include "access/relscan.h" #include "hnsw.h" +#include "lib/pairingheap.h" +#include "miscadmin.h" +#include "nodes/pg_list.h" #include "pgstat.h" -#include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/float.h" #include "utils/memutils.h" +#include "utils/relcache.h" +#include "utils/snapmgr.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif /* * Algorithm 5 from paper diff --git a/src/hnswutils.c b/src/hnswutils.c index 13ecb9d9b..64f449e01 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -2,18 +2,20 @@ #include +#include "access/genam.h" #include "access/generic_xlog.h" -#include "catalog/pg_type.h" -#include "catalog/pg_type_d.h" #include "common/hashfn.h" #include "fmgr.h" #include "hnsw.h" #include "lib/pairingheap.h" +#include "nodes/pg_list.h" +#include "port/atomics.h" #include "sparsevec.h" #include "storage/bufmgr.h" #include "utils/datum.h" #include "utils/memdebug.h" #include "utils/rel.h" +#include "vector.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 1469874d0..5de9b43b5 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -1,13 +1,14 @@ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/generic_xlog.h" #include "commands/vacuum.h" #include "hnsw.h" +#include "nodes/pg_list.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 7166b7da3..d3f3c2415 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -2,23 +2,32 @@ #include +#include "access/genam.h" +#include "access/generic_xlog.h" +#include "access/itup.h" +#include "access/relscan.h" #include "access/table.h" #include "access/tableam.h" +#include "access/tupdesc.h" #include "access/parallel.h" #include "access/xact.h" -#include "bitvec.h" +#include "access/xloginsert.h" #include "catalog/index.h" #include "catalog/pg_operator_d.h" #include "catalog/pg_type_d.h" #include "commands/progress.h" -#include "halfvec.h" +#include "fmgr.h" #include "ivfflat.h" #include "miscadmin.h" +#include "nodes/execnodes.h" #include "optimizer/optimizer.h" #include "storage/bufmgr.h" #include "tcop/tcopprot.h" #include "utils/memutils.h" -#include "vector.h" +#include "utils/rel.h" +#include "utils/sampling.h" +#include "utils/snapmgr.h" +#include "utils/tuplesort.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/ivfflat.c b/src/ivfflat.c index 31c2f7d5e..49c14783f 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -3,14 +3,19 @@ #include #include "access/amapi.h" +#include "access/genam.h" #include "access/reloptions.h" #include "commands/progress.h" #include "commands/vacuum.h" +#include "fmgr.h" #include "ivfflat.h" +#include "nodes/pg_list.h" #include "utils/float.h" #include "utils/guc.h" +#include "utils/relcache.h" #include "utils/selfuncs.h" #include "utils/spccache.h" +#include "vector.h" #if PG_VERSION_NUM < 150000 #define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x) diff --git a/src/ivfinsert.c b/src/ivfinsert.c index ebc61e49d..f9f08d8c1 100644 --- a/src/ivfinsert.c +++ b/src/ivfinsert.c @@ -2,11 +2,16 @@ #include +#include "access/genam.h" #include "access/generic_xlog.h" +#include "access/itup.h" +#include "fmgr.h" #include "ivfflat.h" +#include "nodes/execnodes.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" /* * Find the list that minimizes the distance function diff --git a/src/ivfscan.c b/src/ivfscan.c index b42ada15d..dda1da2be 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -2,15 +2,26 @@ #include +#include "access/genam.h" +#include "access/itup.h" #include "access/relscan.h" +#include "access/tupdesc.h" #include "catalog/pg_operator_d.h" #include "catalog/pg_type_d.h" +#include "fmgr.h" #include "lib/pairingheap.h" #include "ivfflat.h" #include "miscadmin.h" #include "pgstat.h" #include "storage/bufmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" +#include "utils/snapmgr.h" +#include "utils/tuplesort.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif #define GetScanList(ptr) pairingheap_container(IvfflatScanList, ph_node, ptr) #define GetScanListConst(ptr) pairingheap_const_container(IvfflatScanList, ph_node, ptr) diff --git a/src/ivfutils.c b/src/ivfutils.c index 9596391be..f1586dd97 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -1,13 +1,19 @@ #include "postgres.h" +#include "access/genam.h" #include "access/generic_xlog.h" -#include "bitvec.h" -#include "catalog/pg_type.h" #include "fmgr.h" #include "halfutils.h" #include "halfvec.h" #include "ivfflat.h" #include "storage/bufmgr.h" +#include "utils/relcache.h" +#include "utils/varbit.h" +#include "vector.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif /* * Allocate a vector array diff --git a/src/ivfvacuum.c b/src/ivfvacuum.c index 750cdd65a..5408609d3 100644 --- a/src/ivfvacuum.c +++ b/src/ivfvacuum.c @@ -1,9 +1,12 @@ #include "postgres.h" +#include "access/genam.h" #include "access/generic_xlog.h" +#include "access/itup.h" #include "commands/vacuum.h" #include "ivfflat.h" #include "storage/bufmgr.h" +#include "utils/relcache.h" #if PG_VERSION_NUM >= 180000 #define vacuum_delay_point() vacuum_delay_point(false) From 3d6dd20469ef0e068e9678c89d16f7a6cd17b64d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 16:28:45 -0800 Subject: [PATCH 83/85] Removed unneeded check --- src/hnswutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hnswutils.c b/src/hnswutils.c index 64f449e01..f4e4d824b 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -928,7 +928,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in continue; } - if (eElement == NULL || !(eDistance < f->distance || alwaysAdd)) + if (!(eDistance < f->distance || alwaysAdd)) { if (discarded != NULL) { From d557f1c9b1416fe004294f5fcdda64244a832e60 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 23:22:56 -0800 Subject: [PATCH 84/85] Added link to pgvector-tcl [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a1085204f..8e44c1a11 100644 --- a/README.md +++ b/README.md @@ -803,6 +803,7 @@ Raku | [pgvector-raku](https://github.com/pgvector/pgvector-raku) Ruby | [pgvector-ruby](https://github.com/pgvector/pgvector-ruby), [Neighbor](https://github.com/ankane/neighbor) Rust | [pgvector-rust](https://github.com/pgvector/pgvector-rust) Swift | [pgvector-swift](https://github.com/pgvector/pgvector-swift) +Tcl | [pgvector-tcl](https://github.com/pgvector/pgvector-tcl) Zig | [pgvector-zig](https://github.com/pgvector/pgvector-zig) ## Frequently Asked Questions From df2c3d301f962ae41e31131b5ad3c2115e259dc1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 13 Dec 2025 11:33:35 -0800 Subject: [PATCH 85/85] Added link to pgvector-cobol [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8e44c1a11..5f24eb92f 100644 --- a/README.md +++ b/README.md @@ -776,6 +776,7 @@ Algol | [pgvector-algol](https://github.com/pgvector/pgvector-algol) C | [pgvector-c](https://github.com/pgvector/pgvector-c) C++ | [pgvector-cpp](https://github.com/pgvector/pgvector-cpp) C#, F#, Visual Basic | [pgvector-dotnet](https://github.com/pgvector/pgvector-dotnet) +COBOL | [pgvector-cobol](https://github.com/pgvector/pgvector-cobol) Crystal | [pgvector-crystal](https://github.com/pgvector/pgvector-crystal) D | [pgvector-d](https://github.com/pgvector/pgvector-d) Dart | [pgvector-dart](https://github.com/pgvector/pgvector-dart)