PostgreSQL 向量扩展插件pgvector安装和使用
文章目录PostgreSQL 向量扩展插件pgvector安装和使用安装postgresqlpgvector下载和安装安装错误调试错误调试1尝试解决 AP1 启动postgresql错误调试2尝试解决 AP2 : 使用apt-get install postgresql-server错误调试3尝试解决 AP3 卸载apt-get 安装错误调试4设置环境变量PG_CONFIG编译成功使用pgvector测试例列出当前数据库中已安装的扩展extensions参考PostgreSQL 向量扩展插件pgvector安装和使用pgvector 是一个 PostgreSQL 扩展能够让PostgreSQL 提供向量vector数据类型和相关操作功能。参考https://github.com/pgvector/pgvector安装postgresql利用pgvector 前提是事先安装好postgresql安装postgresql例可参考下文。参考LinuxUbuntu源码安装postgresql16.3https://editor.csdn.net/md/articleId142500497pgvector下载和安装安装命令如下cd git clone --branch v0.7.4 https://github.com/pgvector/pgvector.git cd pgvector make make install # may need sudo参考https://github.com/pgvector/pgvector例下载rootautodl-container-616f40a3b3-41cb82d9:~# su - postgres postgresautodl-container-616f40a3b3-41cb82d9:~$ pwd /var/lib/postgresql postgresautodl-container-616f40a3b3-41cb82d9:~$ ls 10 pgsql16 postgresql-16.3 postgresql-16.3.tar.gz postgresautodl-container-616f40a3b3-41cb82d9:~$ git clone --branch v0.7.4 https://github.com/pgvector/pgvector.git Cloning into pgvector... remote: Enumerating objects: 10650, done. remote: Counting objects: 100% (4165/4165), done. remote: Compressing objects: 100% (954/954), done. remote: Total 10650 (delta 3388), reused 3493 (delta 3193), pack-reused 6485 (from 1) Receiving objects: 100% (10650/10650), 1.60 MiB | 544.00 KiB/s, done. Resolving deltas: 100% (7952/7952), done. Note: checking out 103ac50f1a90b47a72003e8e8628a55ec372f202. You are in detached HEAD state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new-branch-name postgresautodl-container-616f40a3b3-41cb82d9:~$安装错误调试错误调试1尝试编译和安装例postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. cp sql/vector.sql sql/vector--0.7.4.sql编译时候汇报如上错误可能是由于postgresql没有启动。postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ psql psql: error: connection to server on socket /tmp/.s.PGSQL.5432 failed: Connection refused Is the server running locally and accepting connections on that socket? postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ postgresautodl-container-616f40a3b3-41cb82d9:~$ ps -xf|grep postgres 1504 pts/3 S 0:00 _ grep postgres postgresautodl-container-616f40a3b3-41cb82d9:~$ pg_ctl -D /var/lib/postgresql/pgsql16/data status pg_ctl: no server running尝试解决 AP1 启动postgresqlpostgresautodl-container-616f40a3b3-41cb82d9:~$ pg_ctl -D /var/lib/postgresql/pgsql16/data -l logfile start pg_ctl: another server might be running; trying to start server anyway waiting for server to start.... done server started postgresautodl-container-616f40a3b3-41cb82d9:~$ ps -xf|grep postgres 1197 pts/0 S 0:00 _ grep postgres 1188 ? Ss 0:00 /var/lib/postgresql/pgsql16/bin/postgres -D /var/lib/postgresql/pgsql16/data 1189 ? Ss 0:00 _ postgres: checkpointer 1190 ? Ss 0:00 _ postgres: background writer 1192 ? Ss 0:00 _ postgres: walwriter 1193 ? Ss 0:00 _ postgres: autovacuum launcher 1194 ? Ss 0:00 _ postgres: logical replication launcher postgresautodl-container-616f40a3b3-41cb82d9:~$ psql psql (16.3) Type help for help. postgres# help You are using psql, the command-line interface to PostgreSQL. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit postgres#错误调试2再次编译出错。postgresautodl-container-616f40a3b3-41cb82d9:~$ pwd /var/lib/postgresql postgresautodl-container-616f40a3b3-41cb82d9:~$ cd pgvector postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. make: Nothing to be done for all. postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ postgres --version postgres (PostgreSQL) 16.3 postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ psql --version psql (PostgreSQL) 16.3无法识别postgresql-server-dev-X.Y 。尝试解决 AP2 : 使用apt-get install postgresql-serverpostgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ apt-get install postgresql-server* E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ exit logout rootautodl-container-616f40a3b3-41cb82d9:~# apt-get install postgresql-server* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting postgresql-server-dev-all for glob postgresql-server* Note, selecting postgresql-server for glob postgresql-server* Note, selecting postgresql-server-dev-10 for glob postgresql-server* The following additional packages will be installed: dctrl-tools iproute2 libatm1 libmnl0 libpq-dev libxtables12 Suggested packages: debtags iproute2-doc postgresql-doc-10 The following NEW packages will be installed: dctrl-tools iproute2 libatm1 libmnl0 libpq-dev libxtables12 postgresql-server-dev-10 postgresql-server-dev-all 0 upgraded, 8 newly installed, 0 to remove and 169 not upgraded. Need to get 1983 kB of archives. After this operation, 10.9 MB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libmnl0 amd64 1.0.4-2 [12.3 kB] Get:2 https://repo.huaweicloud.com/ubuntu bionic-updates/main amd64 iproute2 amd64 4.15.0-2ubuntu1.3 [721 kB] Get:3 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libatm1 amd64 1:2.5.1-2build1 [21.9 kB] Get:4 https://repo.huaweicloud.com/ubuntu bionic-updates/main amd64 libxtables12 amd64 1.6.1-2ubuntu2.1 [28.1 kB] Get:5 https://repo.huaweicloud.com/ubuntu bionic/main amd64 dctrl-tools amd64 2.24-2build1 [60.9 kB] Get:6 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpq-dev amd64 10.23-0ubuntu0.18.04.2 [219 kB] Get:7 https://repo.huaweicloud.com/ubuntu bionic-security/universe amd64 postgresql-server-dev-10 amd64 10.23-0ubuntu0.18.04.2 [905 kB] Get:8 https://repo.huaweicloud.com/ubuntu bionic-security/universe amd64 postgresql-server-dev-all all 190ubuntu0.1 [14.1 kB] Fetched 1983 kB in 1s (3436 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libmnl0:amd64. (Reading database ... 44409 files and directories currently installed.) Preparing to unpack .../0-libmnl0_1.0.4-2_amd64.deb ... Unpacking libmnl0:amd64 (1.0.4-2) ... Selecting previously unselected package iproute2. Preparing to unpack .../1-iproute2_4.15.0-2ubuntu1.3_amd64.deb ... Unpacking iproute2 (4.15.0-2ubuntu1.3) ... Selecting previously unselected package libatm1:amd64. Preparing to unpack .../2-libatm1_1%3a2.5.1-2build1_amd64.deb ... Unpacking libatm1:amd64 (1:2.5.1-2build1) ... Selecting previously unselected package libxtables12:amd64. Preparing to unpack .../3-libxtables12_1.6.1-2ubuntu2.1_amd64.deb ... Unpacking libxtables12:amd64 (1.6.1-2ubuntu2.1) ... Selecting previously unselected package dctrl-tools. Preparing to unpack .../4-dctrl-tools_2.24-2build1_amd64.deb ... Unpacking dctrl-tools (2.24-2build1) ... Selecting previously unselected package libpq-dev. Preparing to unpack .../5-libpq-dev_10.23-0ubuntu0.18.04.2_amd64.deb ... Unpacking libpq-dev (10.23-0ubuntu0.18.04.2) ... Selecting previously unselected package postgresql-server-dev-10. Preparing to unpack .../6-postgresql-server-dev-10_10.23-0ubuntu0.18.04.2_amd64.deb ... Unpacking postgresql-server-dev-10 (10.23-0ubuntu0.18.04.2) ... Selecting previously unselected package postgresql-server-dev-all. Preparing to unpack .../7-postgresql-server-dev-all_190ubuntu0.1_all.deb ... Unpacking postgresql-server-dev-all (190ubuntu0.1) ... Setting up libpq-dev (10.23-0ubuntu0.18.04.2) ... Setting up dctrl-tools (2.24-2build1) ... Setting up postgresql-server-dev-10 (10.23-0ubuntu0.18.04.2) ... Setting up libatm1:amd64 (1:2.5.1-2build1) ... Setting up libxtables12:amd64 (1.6.1-2ubuntu2.1) ... Setting up libmnl0:amd64 (1.0.4-2) ... Setting up iproute2 (4.15.0-2ubuntu1.3) ... Setting up postgresql-server-dev-all (190ubuntu0.1) ... Processing triggers for libc-bin (2.27-3ubuntu1.2) ... rootautodl-container-616f40a3b3-41cb82d9:~#安装的版本不是最新的版本而是10.23。错误调试3再次编译。postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -g -g -O2 -fdebug-prefix-map/build/postgresql-10-XHR5kl/postgresql-10-10.23. -fstack-protector-strong -Wformat -Werrorformat-security -fno-omit-frame-pointer -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -I. -I./ -I/usr/include/postgresql/10/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c -o src/bitutils.o src/bitutils.c In file included from src/bitutils.c:3:0: src/bitutils.h:8:2: error: #error Requires PostgreSQL 12 #error Requires PostgreSQL 12 ^~~~~ src/bitutils.c:5:10: fatal error: port/pg_bitutils.h: No such file or directory #include port/pg_bitutils.h ^~~~~~~~~~~~~~~~~~~~ compilation terminated. builtin: recipe for target src/bitutils.o failed make: *** [src/bitutils.o] Error 1 postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$make编译调用的postgresql不是之前安装的 16.3而是apt-get 安装的10.23版本。尝试解决 AP3 卸载apt-get 安装卸载apt-get 安装的10.23版本参考卸载apt-get 安装的PostgreSQL版本https://blog.csdn.net/lukeUnique/article/details/142610650错误调试4再次编译。rootautodl-container-616f40a3b3-41cb82d9:~# su - postgres postgresautodl-container-616f40a3b3-41cb82d9:~$ cd /var/lib/postgresql/pgvector postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ ls CHANGELOG.md Dockerfile LICENSE META.json Makefile Makefile.win README.md logfile sql src test vector.control postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make Makefile:48: /usr/lib/postgresql/10/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory make: *** No rule to make target /usr/lib/postgresql/10/lib/pgxs/src/makefiles/pgxs.mk. Stop. postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$make编译pgvector时无法识别安装的postgresql。设置环境变量PG_CONFIG为了让make命令找到安装的postgresql 16.3版本。重新修改.bash_profile配置PG_CONFIG和LD_LIBRARY_PATH指定安装的postgresql 16.3版本。例$ vi .bash_profile修改成如下内容。# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export PG_HOME/var/lib/postgresql/pgsql16 export LD_LIBRARY_PATH$LD_LIBRARY_PATH:/var/lib/postgresql/pgsql16/lib export PG_CONFIG/var/lib/postgresql/pgsql16/bin/pg_config export PGDATA/var/lib/postgresql/pgsql16/data PATH$PATH:$HOME/.local/bin:$HOME/bin:$PG_HOME/bin alias psql/var/lib/postgresql/pgsql16/bin/psql export PATH编译成功根据上面的错误调试过程我们可以看到在编译时候需要配置PG_CONFIG。rootautodl-container-616f40a3b3-41cb82d9:~# su - postgres postgresautodl-container-616f40a3b3-41cb82d9:~$ ls logfile pgsql16 pgvector postgresql-16.3 postgresql-16.3.tar.gz postgresautodl-container-616f40a3b3-41cb82d9:~$ cd pgvector postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ ls CHANGELOG.md Dockerfile LICENSE META.json Makefile Makefile.win README.md logfile sql src test vector.control postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/bitutils.o src/bitutils.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/bitvec.o src/bitvec.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/halfutils.o src/halfutils.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/halfvec.o src/halfvec.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnsw.o src/hnsw.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnswbuild.o src/hnswbuild.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnswinsert.o src/hnswinsert.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnswscan.o src/hnswscan.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnswutils.o src/hnswutils.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/hnswvacuum.o src/hnswvacuum.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfbuild.o src/ivfbuild.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfflat.o src/ivfflat.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfinsert.o src/ivfinsert.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfkmeans.o src/ivfkmeans.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfscan.o src/ivfscan.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfutils.o src/ivfutils.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/ivfvacuum.o src/ivfvacuum.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/sparsevec.o src/sparsevec.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -I. -I./ -I/var/lib/postgresql/pgsql16/include/server -I/var/lib/postgresql/pgsql16/include/internal -D_GNU_SOURCE -c -o src/vector.o src/vector.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werrorvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough3 -Wshadowcompatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precisionstandard -Wno-format-truncation -O2 -marchnative -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math -fPIC -fvisibilityhidden -shared -o vector.so src/bitutils.o src/bitvec.o src/halfutils.o src/halfvec.o src/hnsw.o src/hnswbuild.o src/hnswinsert.o src/hnswscan.o src/hnswutils.o src/hnswvacuum.o src/ivfbuild.o src/ivfflat.o src/ivfinsert.o src/ivfkmeans.o src/ivfscan.o src/ivfutils.o src/ivfvacuum.o src/sparsevec.o src/vector.o -L/var/lib/postgresql/pgsql16/lib -Wl,--as-needed -Wl,-rpath,/var/lib/postgresql/pgsql16/lib,--enable-new-dtags -fvisibilityhidden postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$make installpostgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ make install /bin/mkdir -p /var/lib/postgresql/pgsql16/lib /bin/mkdir -p /var/lib/postgresql/pgsql16/share/extension /bin/mkdir -p /var/lib/postgresql/pgsql16/share/extension /usr/bin/install -c -m 755 vector.so /var/lib/postgresql/pgsql16/lib/vector.so /usr/bin/install -c -m 644 .//vector.control /var/lib/postgresql/pgsql16/share/extension/ /usr/bin/install -c -m 644 .//sql/vector--0.5.0--0.5.1.sql .//sql/vector--0.1.3--0.1.4.sql .//sql/vector--0.1.1--0.1.3.sql .//sql/vector--0.4.3--0.4.4.sql .//sql/vector--0.1.7--0.1.8.sql .//sql/vector--0.2.0--0.2.1.sql .//sql/vector--0.1.5--0.1.6.sql .//sql/vector--0.5.1--0.6.0.sql .//sql/vector--0.3.1--0.3.2.sql .//sql/vector--0.1.8--0.2.0.sql .//sql/vector--0.2.6--0.2.7.sql .//sql/vector--0.3.0--0.3.1.sql .//sql/vector--0.4.2--0.4.3.sql .//sql/vector--0.6.2--0.7.0.sql .//sql/vector--0.1.4--0.1.5.sql .//sql/vector--0.2.7--0.3.0.sql .//sql/vector--0.6.0--0.6.1.sql .//sql/vector--0.4.1--0.4.2.sql .//sql/vector--0.7.3--0.7.4.sql .//sql/vector--0.4.0--0.4.1.sql .//sql/vector--0.7.1--0.7.2.sql .//sql/vector--0.1.0--0.1.1.sql .//sql/vector--0.2.3--0.2.4.sql .//sql/vector--0.1.6--0.1.7.sql .//sql/vector--0.3.2--0.4.0.sql .//sql/vector--0.2.5--0.2.6.sql .//sql/vector--0.4.4--0.5.0.sql .//sql/vector--0.2.1--0.2.2.sql .//sql/vector--0.7.2--0.7.3.sql .//sql/vector--0.7.0--0.7.1.sql .//sql/vector--0.2.2--0.2.3.sql .//sql/vector--0.6.1--0.6.2.sql .//sql/vector--0.2.4--0.2.5.sql sql/vector--0.7.4.sql /var/lib/postgresql/pgsql16/share/extension/ /bin/mkdir -p /var/lib/postgresql/pgsql16/include/server/extension/vector/ /usr/bin/install -c -m 644 .//src/halfvec.h .//src/sparsevec.h .//src/vector.h /var/lib/postgresql/pgsql16/include/server/extension/vector/ postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$pgvector的安装成功。使用pgvector使用参考https://github.com/pgvector/pgvectorGetting Started Enable the extension (do this once in each database where you want to use it) CREATE EXTENSION vector; Create a vector column with 3 dimensions CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3)); Insert vectors INSERT INTO items (embedding) VALUES ([1,2,3]), ([4,5,6]); 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) Note: # returns the negative inner product since Postgres only supports ASC order index scans on operators测试例postgresautodl-container-616f40a3b3-41cb82d9:~/pgvector$ psql psql (16.3) Type help for help. postgres# CREATE EXTENSION vector; CREATE EXTENSION postgres# CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3)); CREATE TABLE postgres# INSERT INTO items (embedding) VALUES ([1,2,3]), ([4,5,6]); INSERT 0 2 postgres# SELECT * FROM items ORDER BY embedding - [3,1,2] LIMIT 5; id | embedding --------------- 1 | [1,2,3] 2 | [4,5,6] (2 rows)列出当前数据库中已安装的扩展extensionspostgres# dx List of installed extensions Name | Version | Schema | Description ------------------------------------------------------------------------------------ plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language vector | 0.7.4 | public | vector data type and ivfflat and hnsw access methods (2 rows) postgres#参考实战PG vector 构建DBA 个人知识库之二: 向量数据库与 PG vector 介绍https://pgfans.cn/a/3606数据库技术核心向量检索pgvectorhttps://blog.csdn.net/ChaoMing_H/article/details/141257149PostgreSQL向量数据插件–pgvector安装附PostgreSQL安装https://blog.csdn.net/m0_62627802/article/details/135027327

相关新闻

Python工业网关性能翻倍实录:从200点/s到5000点/s的7步调优全流程(含OPC UA+MQTT双协议压测数据)

Python工业网关性能翻倍实录:从200点/s到5000点/s的7步调优全流程(含OPC UA+MQTT双协议压测数据)

第一章:Python工业网关性能翻倍实录:从200点/s到5000点/s的7步调优全流程(含OPC UAMQTT双协议压测数据)在某智能产线边缘侧网关项目中,基于 Python 构建的轻量级工业协议转换网关初始吞吐仅 200 点/秒(以 1…

2026/7/5 15:10:48 阅读更多 →
当热键遭遇劫持:如何用技术侦探思维破解系统快捷键冲突

当热键遭遇劫持:如何用技术侦探思维破解系统快捷键冲突

当热键遭遇劫持:如何用技术侦探思维破解系统快捷键冲突 【免费下载链接】hotkey-detective A small program for investigating stolen hotkeys under Windows 8 项目地址: https://gitcode.com/gh_mirrors/ho/hotkey-detective 一、案件诊断:热键…

2026/7/4 3:55:25 阅读更多 →
泛微Ecology9.0流程二开实战:用Ecode实现浏览框自动填充(附完整代码)

泛微Ecology9.0流程二开实战:用Ecode实现浏览框自动填充(附完整代码)

泛微Ecology9.0流程二开深度实战:Ecode赋能浏览框智能填充的架构设计与工程实践 在泛微Ecology9.0的流程表单开发中,浏览框字段的自动填充是一个高频且颇具挑战的需求。无论是为了提升用户体验,减少手动选择的繁琐,还是为了实现基…

2026/7/2 11:11:42 阅读更多 →

最新新闻

大模型开源项目安全审计实战:从Llama-recipes漏洞分析到安全开发流水线构建

大模型开源项目安全审计实战:从Llama-recipes漏洞分析到安全开发流水线构建

1. 项目概述:为什么开源项目也需要安全审计?最近在社区里看到不少朋友在讨论大模型应用开发,尤其是基于 Meta 的 Llama 系列模型进行微调和部署。Llama-recipes 作为 Meta 官方推出的一个工具集,提供了从数据准备、模型微调到部署…

2026/7/5 22:02:45 阅读更多 →
YOLOv12对抗性特征增强训练原理与实战

YOLOv12对抗性特征增强训练原理与实战

1. YOLOv12与对抗性特征增强训练的背景解析YOLOv12作为2025年发布的注意力中心型物体检测器,其核心创新在于区域注意力机制(Area Attention)和R-ELAN架构。与传统CNN-based的YOLO系列不同,YOLOv12通过将特征图划分为多个水平或垂直…

2026/7/5 22:00:45 阅读更多 →
PatchMatchStereo 与 SGM 性能对比:Middlebury数据集上的5项指标实测

PatchMatchStereo 与 SGM 性能对比:Middlebury数据集上的5项指标实测

PatchMatchStereo与SGM立体匹配算法深度评测:Middlebury数据集5维性能对比1. 立体匹配算法技术背景与评测意义立体匹配作为计算机视觉三维重建的核心环节,其算法选择直接影响深度估计的精度与效率。在众多经典算法中,基于倾斜支持窗口的Patch…

2026/7/5 22:00:45 阅读更多 →
Gobuster字典工程实战:从基础配置到分层扫描策略

Gobuster字典工程实战:从基础配置到分层扫描策略

1. 项目概述:为什么你的Gobuster总是“刮痧”? 如果你做过Web目录或子域名枚举,大概率用过Gobuster。这个用Go语言写的工具,速度快、资源占用低,是渗透测试和漏洞赏金猎人武器库里的常客。但很多人用起来总觉得差点意思…

2026/7/5 22:00:45 阅读更多 →
YOLO26目标检测优化:SOCA二阶通道注意力机制详解

YOLO26目标检测优化:SOCA二阶通道注意力机制详解

1. 项目概述在计算机视觉领域,目标检测一直是核心研究方向之一。YOLO系列算法因其出色的实时性和准确性,成为工业界和学术界广泛采用的主流框架。最近发布的YOLO26版本在检测精度和速度上都有了显著提升,但特征提取网络仍然存在优化空间。本文…

2026/7/5 21:58:44 阅读更多 →
计算机视觉中的目标跟踪技术:原理与应用

计算机视觉中的目标跟踪技术:原理与应用

1. 目标跟踪技术概述目标跟踪作为计算机视觉领域的核心技术之一,其核心任务是在连续的视频帧序列中持续定位并关联一个或多个特定目标。这项技术需要处理各种复杂场景,包括光照变化、目标遮挡、形态变化等挑战,最终输出目标的位置、运动轨迹和…

2026/7/5 21:58:44 阅读更多 →

日新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/5 0:03:34 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/5 0:03:34 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/5 0:07:38 阅读更多 →

周新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/5 0:03:34 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/5 0:03:34 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/5 0:07:38 阅读更多 →

月新闻