mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-22 03:57:34 +08:00
Compare commits
5 Commits
v0.8.1
...
parallel-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6058beeda | ||
|
|
9e29dff78c | ||
|
|
13c0dbf530 | ||
|
|
c205a12107 | ||
|
|
db3755a58f |
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
@@ -49,9 +49,9 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- postgres: 17
|
||||
os: macos-15
|
||||
os: macos-26
|
||||
- postgres: 14
|
||||
os: macos-13
|
||||
os: macos-15-intel
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ankane/setup-postgres@v1
|
||||
@@ -72,27 +72,35 @@ 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
|
||||
- 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: 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
|
||||
|
||||
@@ -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)"
|
||||
|
||||
@@ -143,6 +143,10 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
||||
*indexSelectivity = costs.indexSelectivity;
|
||||
*indexCorrelation = costs.indexCorrelation;
|
||||
*indexPages = costs.numIndexPages;
|
||||
|
||||
elog(INFO, "ivfflatcostestimate = %f", costs.indexTotalCost);
|
||||
/* Cost estimates for parallel workers applied outside of amcostestimate */
|
||||
elog(INFO, "parallel_workers = %d, parallel aware = %d", path->path.parallel_workers, path->path.parallel_aware);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -170,6 +174,25 @@ ivfflatvalidate(Oid opclassoid)
|
||||
return true;
|
||||
}
|
||||
|
||||
static Size
|
||||
ivfflatestimateparallelscan()
|
||||
{
|
||||
elog(INFO, "ivfflatestimateparallelscan");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ivfflatinitparallelscan(void *target)
|
||||
{
|
||||
elog(INFO, "ivfflatinitparallelscan");
|
||||
}
|
||||
|
||||
static void
|
||||
ivfflatparallelrescan(IndexScanDesc scan)
|
||||
{
|
||||
elog(INFO, "ivfflatparallelrescan");
|
||||
}
|
||||
|
||||
/*
|
||||
* Define index handler
|
||||
*
|
||||
@@ -200,7 +223,7 @@ ivfflathandler(PG_FUNCTION_ARGS)
|
||||
amroutine->amstorage = false;
|
||||
amroutine->amclusterable = false;
|
||||
amroutine->ampredlocks = false;
|
||||
amroutine->amcanparallel = false;
|
||||
amroutine->amcanparallel = true;
|
||||
#if PG_VERSION_NUM >= 170000
|
||||
amroutine->amcanbuildparallel = true;
|
||||
#endif
|
||||
@@ -242,9 +265,9 @@ ivfflathandler(PG_FUNCTION_ARGS)
|
||||
amroutine->amrestrpos = NULL;
|
||||
|
||||
/* Interface functions to support parallel index scans */
|
||||
amroutine->amestimateparallelscan = NULL;
|
||||
amroutine->aminitparallelscan = NULL;
|
||||
amroutine->amparallelrescan = NULL;
|
||||
amroutine->amestimateparallelscan = ivfflatestimateparallelscan;
|
||||
amroutine->aminitparallelscan = ivfflatinitparallelscan;
|
||||
amroutine->amparallelrescan = ivfflatparallelrescan;
|
||||
|
||||
#if PG_VERSION_NUM >= 180000
|
||||
amroutine->amtranslatestrategy = NULL;
|
||||
|
||||
@@ -119,6 +119,9 @@ GetScanItems(IndexScanDesc scan, Datum value)
|
||||
|
||||
tuplesort_reset(so->sortstate);
|
||||
|
||||
if (scan->parallel_scan != NULL)
|
||||
elog(INFO, "parallel scan");
|
||||
|
||||
/* Search closest probes lists */
|
||||
while (so->listIndex < so->maxProbes && (++batchProbes) <= so->probes)
|
||||
{
|
||||
|
||||
16
test/sql/ivfflat_parallel.sql
Normal file
16
test/sql/ivfflat_parallel.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- SET force_parallel_mode = on;
|
||||
SET parallel_setup_cost = 10;
|
||||
SET parallel_tuple_cost = 0.000001;
|
||||
SET min_parallel_table_scan_size = 1;
|
||||
SET min_parallel_index_scan_size = 1;
|
||||
|
||||
CREATE TABLE t (id integer, val vector(3));
|
||||
ALTER TABLE t ALTER COLUMN val SET STORAGE PLAIN;
|
||||
INSERT INTO t (id, val) SELECT n, ARRAY[random(), random(), random()] FROM generate_series(1,1000000) n;
|
||||
CREATE INDEX ON t USING ivfflat (val) WITH (lists = 10);
|
||||
SET ivfflat.probes = 4;
|
||||
|
||||
EXPLAIN SELECT * FROM t ORDER BY val <-> '[0.5,0.5,0.5]' LIMIT 5;
|
||||
SELECT * FROM t ORDER BY val <-> '[0.5,0.5,0.5]' LIMIT 5;
|
||||
|
||||
DROP TABLE t;
|
||||
Reference in New Issue
Block a user