mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-22 20:15:46 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88ba5da6a7 | ||
|
|
6a550c8b52 | ||
|
|
5748cb6b43 | ||
|
|
60814b8f39 | ||
|
|
773a63bed1 | ||
|
|
955a5a6082 | ||
|
|
8863920fdc | ||
|
|
6d9653d763 | ||
|
|
3a488c9f2f | ||
|
|
fe133bfe5d | ||
|
|
e279bb3d7e | ||
|
|
0aa39a8c0c |
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
@@ -3,20 +3,37 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
postgres: [13, 12, 11, 10, 9.6]
|
||||
include:
|
||||
- os: macos-latest
|
||||
postgres: 13
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ankane/setup-postgres@v1
|
||||
with:
|
||||
postgres-version: ${{ matrix.postgres }}
|
||||
- run: sudo apt-get update && sudo apt-get install postgresql-server-dev-${{ matrix.postgres }} libipc-run-perl
|
||||
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
|
||||
run: sudo apt-get update && sudo apt-get install postgresql-server-dev-${{ matrix.postgres }} libipc-run-perl
|
||||
- run: make
|
||||
- run: |
|
||||
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
|
||||
run: |
|
||||
export PG_CONFIG=`which pg_config`
|
||||
sudo --preserve-env=PG_CONFIG make install
|
||||
- if: ${{ startsWith(matrix.os, 'macos') }}
|
||||
run: make install
|
||||
- run: make installcheck
|
||||
- run: make prove_installcheck
|
||||
- if: ${{ failure() }}
|
||||
run: cat regression.diffs
|
||||
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
|
||||
run: make prove_installcheck
|
||||
- if: ${{ startsWith(matrix.os, 'macos') }}
|
||||
run: |
|
||||
brew install cpanm && cpanm IPC::Run
|
||||
wget -q https://github.com/postgres/postgres/archive/refs/tags/REL_13_2.tar.gz
|
||||
tar xf REL_13_2.tar.gz
|
||||
make prove_installcheck PROVE=prove PERL5LIB=postgres-REL_13_2/src/test/perl
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
## 0.1.2 (2021-04-26)
|
||||
|
||||
- Vectorized distance calculations
|
||||
- Improved cost estimation
|
||||
|
||||
## 0.1.1 (2021-04-25)
|
||||
|
||||
- Added binary representation for `COPY`
|
||||
|
||||
11
Makefile
11
Makefile
@@ -7,6 +7,17 @@ TESTS = $(wildcard sql/*.sql)
|
||||
|
||||
REGRESS = btree cast copy functions ivfflat_cosine ivfflat_ip ivfflat_l2 ivfflat_unlogged vector
|
||||
|
||||
# For auto-vectorization:
|
||||
# - GCC (needs -ftree-vectorize OR -O3) - https://gcc.gnu.org/projects/tree-ssa/vectorization.html
|
||||
# - Clang (could use pragma instead) - https://llvm.org/docs/Vectorizers.html
|
||||
PG_CFLAGS = -march=native -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math
|
||||
|
||||
# Debug GCC auto-vectorization
|
||||
# PG_CFLAGS += -fopt-info-vec
|
||||
|
||||
# Debug Clang auto-vectorization
|
||||
# PG_CFLAGS += -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize
|
||||
|
||||
PG_CONFIG ?= pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS)
|
||||
|
||||
@@ -17,7 +17,7 @@ Supports L2 distance, inner product, and cosine distance
|
||||
Compile and install the extension (supports Postgres 9.6+)
|
||||
|
||||
```sh
|
||||
git clone --branch v0.1.1 https://github.com/ankane/pgvector.git
|
||||
git clone --branch v0.1.2 https://github.com/ankane/pgvector.git
|
||||
cd pgvector
|
||||
make
|
||||
make install # may need sudo
|
||||
@@ -140,7 +140,7 @@ Libraries that use pgvector:
|
||||
|
||||
### 0.1.1
|
||||
|
||||
Follow the [installation instructions](#installation) and run:
|
||||
Compile and install the latest version and run:
|
||||
|
||||
```sql
|
||||
ALTER EXTENSION vector UPDATE TO '0.1.1';
|
||||
|
||||
@@ -29,8 +29,6 @@ _PG_init(void)
|
||||
|
||||
/*
|
||||
* Estimate the cost of an index scan
|
||||
*
|
||||
* TODO Improve cost estimation
|
||||
*/
|
||||
static void
|
||||
ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
@@ -42,6 +40,9 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
)
|
||||
{
|
||||
GenericCosts costs;
|
||||
int lists;
|
||||
double ratio;
|
||||
Relation indexRel;
|
||||
|
||||
#if PG_VERSION_NUM < 120000
|
||||
List *qinfos;
|
||||
@@ -57,7 +58,18 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
genericcostestimate(root, path, loop_count, qinfos, &costs);
|
||||
#endif
|
||||
|
||||
*indexStartupCost = costs.indexStartupCost;
|
||||
indexRel = index_open(path->indexinfo->indexoid, NoLock);
|
||||
lists = IvfflatGetLists(indexRel);
|
||||
index_close(indexRel, NoLock);
|
||||
|
||||
ratio = ((double) ivfflat_probes) / lists;
|
||||
if (ratio > 1)
|
||||
ratio = 1;
|
||||
|
||||
costs.indexTotalCost *= ratio;
|
||||
|
||||
/* Startup cost and total cost are same */
|
||||
*indexStartupCost = costs.indexTotalCost;
|
||||
*indexTotalCost = costs.indexTotalCost;
|
||||
*indexSelectivity = costs.indexSelectivity;
|
||||
*indexCorrelation = costs.indexCorrelation;
|
||||
|
||||
@@ -244,11 +244,10 @@ vector_recv(PG_FUNCTION_ARGS)
|
||||
int32 typmod = PG_GETARG_INT32(2);
|
||||
Vector *result;
|
||||
int16 dim;
|
||||
int16 unused;
|
||||
int i;
|
||||
|
||||
dim = pq_getmsgint(buf, sizeof(int16));
|
||||
unused = pq_getmsgint(buf, sizeof(int16));
|
||||
pq_getmsgint(buf, sizeof(int16)); /* unused */
|
||||
|
||||
CheckDim(dim);
|
||||
CheckExpectedDim(typmod, dim);
|
||||
|
||||
@@ -21,8 +21,9 @@ sub test_index_replay
|
||||
my $caughtup_query;
|
||||
my $server_version_num = $node_primary->safe_psql("postgres", "SHOW server_version_num");
|
||||
if ($server_version_num >= 100000) {
|
||||
$caughtup_query = "SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
|
||||
$caughtup_query = "SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
|
||||
} else {
|
||||
# TODO figure out why replay location doesn't work
|
||||
$caughtup_query = "SELECT pg_current_xlog_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname';";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user