PostgreSQL integration with pg_matlab

简介:
pg_matlab是一个pg插件, 并非一般的过程语言. 使用pg_matlab创建的函数必须转换成c代码后, 编译并在数据库中使用共享库的方式调用.

pg_matlab下载和安装 : 
wget http://www.cybertec.at/download/pg_matlab/pg_matlab-v2.tar.gz
tar -zxvf pg_matlab-v2.tar.gz
mv pg_matlab /opt/soft_bak/postgresql-9.3beta2/contrib/
[root@db-172-16-3-39 contrib]# cd /opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/
[root@db-172-16-3-39 pg_matlab]# . /home/pg93/.bash_profile 
root@db-172-16-3-39-> which pg_config
/opt/pgsql9.3beta2/bin/pg_config
root@db-172-16-3-39-> gmake clean
gmake clean -e -C matcored
gmake[1]: Entering directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/matcored'
rm -f matcored.o mat_wrapper.o matcored
gmake[1]: Leaving directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/matcored'
USE_PGXS=1 gmake clean -e -C libmatpg
gmake[1]: Entering directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/libmatpg'
rm -f matpg.so   libmatpg.a  libmatpg.pc
rm -f create_mat_pg_operators.sql
rm -f mat_pg_funcs.o
gmake[1]: Leaving directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/libmatpg'
root@db-172-16-3-39-> gmake
gmake -e -C matcored
gmake[1]: Entering directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/matcored'
cc -Wall -c -o matcored.o matcored.c -I/extern/include -I../libmatcore/distrib
In file included from matcored.c:15:
../libmatcore/distrib/libmatcore.h:17:22: error: mclmcrrt.h: No such file or directory
In file included from matcored.c:15:
../libmatcore/distrib/libmatcore.h:63: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MW_CALL_CONV’
../libmatcore/distrib/libmatcore.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MW_CALL_CONV’
../libmatcore/distrib/libmatcore.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘libmatcoreTerminate’
../libmatcore/distrib/libmatcore.h:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘libmatcorePrintStackTrace’
../libmatcore/distrib/libmatcore.h:79: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MW_CALL_CONV’
../libmatcore/distrib/libmatcore.h:82: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘libmatcoreGetMcrID’
../libmatcore/distrib/libmatcore.h:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MW_CALL_CONV’
matcored.c: In function ‘send_matcored_response’:
matcored.c:60: warning: implicit declaration of function ‘strncpy’
matcored.c:60: warning: incompatible implicit declaration of built-in function ‘strncpy’
matcored.c:60: warning: implicit declaration of function ‘strlen’
matcored.c:60: warning: incompatible implicit declaration of built-in function ‘strlen’
matcored.c: In function ‘send_matcored_error’:
matcored.c:74: warning: incompatible implicit declaration of built-in function ‘strncpy’
matcored.c:74: warning: incompatible implicit declaration of built-in function ‘strlen’
matcored.c:81: warning: implicit declaration of function ‘memset’
matcored.c:81: warning: incompatible implicit declaration of built-in function ‘memset’
matcored.c: At top level:
matcored.c:99: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘read_int_param’
matcored.c: In function ‘send_int_param’:
matcored.c:141: warning: incompatible implicit declaration of built-in function ‘strncpy’
matcored.c:141: warning: incompatible implicit declaration of built-in function ‘strlen’
matcored.c: At top level:
matcored.c:150: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘read_binary_param’
matcored.c: In function ‘send_binary_param’:
matcored.c:186: warning: incompatible implicit declaration of built-in function ‘strncpy’
matcored.c:186: warning: incompatible implicit declaration of built-in function ‘strlen’
matcored.c: In function ‘init_matcore’:
matcored.c:197: warning: implicit declaration of function ‘libmatcoreInitialize’
matcored.c: In function ‘terminate_matcore’:
matcored.c:207: warning: implicit declaration of function ‘libmatcoreTerminate’
matcored.c: In function ‘add_vector’:
matcored.c:226: warning: implicit declaration of function ‘read_int_param’
matcored.c:231: warning: implicit declaration of function ‘read_binary_param’
matcored.c: In function ‘handle_client’:
matcored.c:276: warning: implicit declaration of function ‘strncmp’
matcored.c:276: warning: incompatible implicit declaration of built-in function ‘strlen’
matcored.c: In function ‘set_sighandler’:
matcored.c:346: warning: incompatible implicit declaration of built-in function ‘memset’
matcored.c: In function ‘listen_on_port’:
matcored.c:371: warning: incompatible implicit declaration of built-in function ‘memset’
matcored.c: In function ‘connect_on_port’:
matcored.c:435: warning: incompatible implicit declaration of built-in function ‘memset’
matcored.c:447: warning: incompatible implicit declaration of built-in function ‘strncpy’
matcored.c: In function ‘main’:
matcored.c:471: warning: implicit declaration of function ‘strcmp’
gmake[1]: *** [matcored.o] Error 1
gmake[1]: Leaving directory `/opt/soft_bak/postgresql-9.3beta2/contrib/pg_matlab/matcored'
gmake: *** [all] Error 2


错误来自libmatcore/distrib/libmatcore.h
/*
 * MATLAB Compiler: 4.13 (R2010a)
 * Date: Thu Feb 10 10:54:51 2011
 * Arguments: "-B" "macro_default" "-W" "lib:libmatcore" "-T" "link:lib" "-d"
 * "/home/babak/Downloads/pg_matlab/libmatcore/src" "-w"
 * "enable:specified_file_mismatch" "-w" "enable:repeated_file" "-w"
 * "enable:switch_ignored" "-w" "enable:missing_lib_sentinel" "-w"
 * "enable:demo_license" "-g" "-G" "-v" "/home/babak/Downloads/pg_matlab/add.m" 
 */
#include "mclmcrrt.h"

头文件不存在, 因此在安装pg_matlab前需要先安装MCR.
unzip MCR_R2012a_glnxa64_installer.zip
修改输入文件文件
vi installer_input.txt
agreeToLicense=yes
product.MATLAB_Compiler

安装 
./install -mode silent -inputFile ./installer_input.txt

安装正常的输出 : 
添加到LD_LIBRARY_PATH
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64
Next, set the XAPPLRESDIR environment variable to the following value:

/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/X11/app-defaults
(Sep 25, 2013 16:02:28) Exiting with status 0
(Sep 25, 2013 16:02:28) End - Successful.
Finished

mcr默认安装到这里来了
root@digoal-PowerEdge-R610-> ll /usr/local/MATLAB/MATLAB_Compiler_Runtime/v717
total 136K
drwxr-xr-x  5 root root 4.0K Sep 25 16:02 appdata
drwxr-xr-x  5 root root 4.0K Sep 25 16:02 bin
drwxr-xr-x  3 root root 4.0K Sep 25 16:02 etc
drwxr-xr-x  4 root root 4.0K Sep 25 16:02 extern
drwxr-xr-x  3 root root 4.0K Sep 25 16:02 help
drwxr-xr-x  4 root root 4.0K Sep 25 16:02 java
-r--r--r--  1 root root  72K Jan 15  2012 license.txt
-r--r--r--  1 root root 5.1K Dec 21  2011 MCR_license.txt
-r--r--r--  1 root root 3.9K Jan  5  2012 patents.txt
drwxr-xr-x 64 root root 4.0K Sep 25 16:02 resources
drwxr-xr-x  3 root root 4.0K Sep 25 16:02 runtime
drwxr-xr-x  3 root root 4.0K Sep 25 16:02 simulink
drwxr-xr-x  8 root root 4.0K Sep 25 16:02 sys
drwxr-xr-x 10 root root 4.0K Sep 25 16:02 toolbox
-r--r--r--  1 root root  248 Dec 26  2007 trademarks.txt
drwxr-xr-x  4 root root 4.0K Sep 25 16:02 X11

在安装pg_matlab前, 接下来要修改几个地方, 
1. pg_matlab

root@digoal-PowerEdge-R610-> pwd
/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/matcored
root@digoal-PowerEdge-R610-> vi Makefile 
修改
PGM_DIR = /opt/pgsql/bin
LIB_DIR = /opt/pgsql/lib
加一行
MATLABROOT=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717

root@digoal-PowerEdge-R610-> pwd
/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab
root@digoal-PowerEdge-R610-> vi Makefile 
修改
MATLABROOT=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717

2. 修改环境变量
su - pg92
把安装mcr时建议的配置加上去
vi .bash_profile
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/sys/java/jre/glnxa64/jre/lib/amd64:$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/X11/app-defaults

3. 安装pg_matlab
root@digoal-PowerEdge-R610-> make clean
make clean -e -C matcored
make[1]: Entering directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/matcored'
rm -f matcored.o mat_wrapper.o matcored
make[1]: Leaving directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/matcored'
USE_PGXS=1 make clean -e -C libmatpg
make[1]: Entering directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'
rm -f matpg.so   libmatpg.a 
rm -f create_mat_pg_operators.sql
rm -f mat_pg_funcs.o
make[1]: Leaving directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'
root@digoal-PowerEdge-R610-> make
make -e -C matcored
make[1]: Entering directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/matcored'
cc -Wall -c -o matcored.o matcored.c -I/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/extern/include -I../libmatcore/distrib
cc -Wall -c -o mat_wrapper.o mat_wrapper.c -I/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/extern/include -I../libmatcore/distrib
gcc -o matcored matcored.o mat_wrapper.o -L/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64 -L../libmatcore/distrib -lmwmclmcrrt -lmatcore
make[1]: Leaving directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/matcored'
USE_PGXS=1 make -e -C libmatpg
make[1]: Entering directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'
sed 's,MODULE_PATHNAME,$libdir/create_mat_pg_operators,g' create_mat_pg_operators.sql.in >create_mat_pg_operators.sql
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -I../matcored -I. -I. -I/opt/pgsql9.2.4/include/server -I/opt/pgsql9.2.4/include/internal -D_GNU_SOURCE -I/usr/include/libxml2   -c -o mat_pg_funcs.o mat_pg_funcs.c
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -shared -o matpg.so mat_pg_funcs.o -L/opt/pgsql9.2.4/lib -L/usr/lib/x86_64-linux-gnu  -Wl,--as-needed -Wl,-rpath,'/opt/pgsql9.2.4/lib',--enable-new-dtags  
make[1]: Leaving directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'
root@digoal-PowerEdge-R610-> make install
cp libmatcore/distrib/libmatcore.so /opt/pgsql/lib
cp matcored/matcored /opt/pgsql/bin
USE_PGXS=1 make install -e -C libmatpg
make[1]: Entering directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'
/bin/mkdir -p '/opt/pgsql9.2.4/lib'
/bin/mkdir -p '/opt/pgsql9.2.4/share/contrib'
/bin/sh /opt/pgsql9.2.4/lib/pgxs/src/makefiles/../../config/install-sh -c -m 755  matpg.so '/opt/pgsql9.2.4/lib/matpg.so'
/bin/sh /opt/pgsql9.2.4/lib/pgxs/src/makefiles/../../config/install-sh -c -m 644  create_mat_pg_operators.sql '/opt/pgsql9.2.4/share/contrib/'
make[1]: Leaving directory `/data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/libmatpg'


4. 修改ld.so.conf
vi /etc/ld.so.conf
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/bin/glnxa64
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64
执行ldconfig, 同时检查是否生效
root@digoal-PowerEdge-R610-> ldconfig
root@digoal-PowerEdge-R610-> ldconfig -p|grep libmwmclmcrrt
        libmwmclmcrrt.so.7.17 (libc6,x86-64) => /usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64/libmwmclmcrrt.so.7.17
        libmwmclmcrrt.so (libc6,x86-64) => /usr/local/MATLAB/MATLAB_Compiler_Runtime/v717/runtime/glnxa64/libmwmclmcrrt.so


启动matcored
root@digoal-PowerEdge-R610-> /opt/pgsql/bin/matcored 54321
pg92@digoal-PowerEdge-R610-> which matcored
/opt/pgsql/bin/matcored
启动matcored时指定监听端口54321
pg92@digoal-PowerEdge-R610-> matcored 54321
pg92@digoal-PowerEdge-R610-> ps -efw|grep matcored
pg92     13041     1  0 16:32 pts/1    00:00:00 matcored 54321
pg92     13043 12932  0 16:32 pts/1    00:00:00 grep --color=auto matcored
pg92@digoal-PowerEdge-R610-> netstat -anp|grep 54321
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:54321         0.0.0.0:*               LISTEN      13041/matcored  


在数据库中创建函数
pg92@digoal-PowerEdge-R610-> cd /data01/soft_bak/postgresql-9.2.4/contrib/pg_matlab/
pg92@digoal-PowerEdge-R610-> cat create_mat_pg_operators.sql 
-- + operator

CREATE OR REPLACE FUNCTION mat_pg_add(DOUBLE PRECISION[], DOUBLE PRECISION[]) RETURNS DOUBLE PRECISION[] 
AS 'libmatpg.so', 'mat_pg_add' 
LANGUAGE C STRICT IMMUTABLE;

DROP OPERATOR + (DOUBLE PRECISION[],DOUBLE PRECISION[]);
CREATE OPERATOR + (
        PROCEDURE = mat_pg_add,
        LEFTARG = DOUBLE PRECISION[],
        RIGHTARG = DOUBLE PRECISION[]
);

报错 : 
pg92@digoal-PowerEdge-R610-> psql -f create_mat_pg_operators.sql 
psql:create_mat_pg_operators.sql:5: ERROR:  could not access file "libmatpg.so": No such file or directory
psql:create_mat_pg_operators.sql:7: ERROR:  operator does not exist: double precision[] + double precision[]
psql:create_mat_pg_operators.sql:12: ERROR:  function mat_pg_add(double precision[], double precision[]) does not exist

这个动态库文件不存在
pg92@digoal-PowerEdge-R610-> ll /opt/pgsql/lib/libmatpg*
ls: cannot access /opt/pgsql/lib/libmatpg*: No such file or directory

解决办法 : 
root@digoal-PowerEdge-R610-> cd /opt/pgsql/lib
root@digoal-PowerEdge-R610-> mv matpg.so libmatpg.so
pg92@digoal-PowerEdge-R610-> psql -f create_mat_pg_operators.sql 
CREATE FUNCTION
psql:create_mat_pg_operators.sql:7: ERROR:  operator does not exist: double precision[] + double precision[]
CREATE OPERATOR


[安装说明]
How to compile, install and run
===============================

Before compilation, you need to set a few environment variables.

- PATH (if needed, if PostgreSQL is installed into a custom directory)
- MATLABROOT, so the Makefiles find the proper include and shared library files
- LD_LIBRARY_PATH or modify /etc/ld.so.conf so the libmatcore.so is found.

The main Makefile has the PGM_DIR and LIB_DIR, matcored and libmatcore.so
are installed there, respectively.

The C header file pg_matlab/libmatpg/mat_pg_funcs.h contains the hardcoded
port number (54321 by default) that the PostgreSQL module will connect to.

After setting all the above, run "make" from the main pg_matlab directory.
Then run "make install", you most likely need to be root to do this, but it
depends on the installation directories.

You need to install the SQL script into the database you want to use Matlab,
replace "dbname" with the proper name in the command below:

$ psql -f libmatpg/create_mat_pg_operators.sql dbname

When it's done, you need to run the installed "matcored" with the following
command:

$ matcored NNN

where NNN is the port number. Use the same port number as you used above.
You should use a special user for running matcored and this user must have
"ulimit -c 0" set, so the core dumps from the failing daemon children don't
fill up the disk.
vi /etc/security/limits.conf
* soft    core    unlimited
* hard    core    unlimited

When matcored is running, you can use commands like these in PostgreSQL
to add two vectors:

SELECT mat_pg_add( '{1,2,3,4}' , '{2,3,4,5}' );

or

SELECT '{1,2,3,4}'::float8[] + '{2,3,4,5}'::float8[];

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
SpringCloudAlibaba 安全 Java
SpringCloud版本升级后bootstrap.yml配置不生效
SpringCloud版本升级后bootstrap.yml配置不生效
2553 1
|
JSON JavaScript API
Node.js(nodejs)对本地JSON文件进行增、删、改、查操作(轻车熟路)
Node.js(nodejs)对本地JSON文件进行增、删、改、查操作(轻车熟路)
|
5月前
|
人工智能 数据可视化 数据挖掘
Gemini-2.5-pro大模型专业画常用图表保姆级教程:圆角环形图+柱状图排序图+系列按行和按列排布图,国内直接使用
虚竹哥推出AI数据可视化工具《xuzhu-huatu-plus》,支持多种图表类型,如柱状图、饼图、热力图等,输入指令即可生成图表代码,大幅简化绘图流程。用户仅需访问指定平台,选择智能体并输入需求,AI即自动完成图表设计,助力高效数据分析与展示。提供免费授权码体验,国内可直接使用。
241 9
|
4月前
|
数据安全/隐私保护 容器 Go
开源IM即时通讯系统调研
Lumen IM 是一款企业级开源即时通讯工具,前端采用 Vue3 + Naive UI,后端基于 Go 语言,使用 WebSocket 协议。支持 Docker + Nginx 快速部署,适合私有化环境。功能包括文本、图片、文件消息,内置笔记、群聊及消息历史记录。界面美观、功能完善,适用于企业沟通、团队协作及开发者学习。提供前后端源码,便于快速搭建 IM 系统。
开源IM即时通讯系统调研
|
6月前
|
SQL 存储 关系型数据库
PostgreSQL窗口函数避坑指南:如何让复杂分析查询提速300%?
本文基于真实企业级案例,深入剖析PostgreSQL窗口函数的执行原理与性能陷阱,提供8大优化策略。通过定制索引、分区裁剪、内存调优及并行处理等手段,将分钟级查询压缩至秒级响应。结合CTE分阶段计算与物化视图技术,解决海量数据分析中的瓶颈问题。某金融客户实践表明,风险分析查询从47秒降至0.8秒,效率提升5800%。文章附带代码均在PostgreSQL 15中验证,助您高效优化SQL性能。
348 0
|
4月前
|
前端开发 JavaScript 算法
如何开发人事及OA管理系统的绩效管理板块?(附架构图+流程图+代码参考)
本文深入解析了人事及OA系统中绩效管理模块的设计与实现,涵盖总体架构、功能模块、业务流程、开发技巧、数据库设计、前后端实现及核心算法等。内容详实,配有架构图、流程图和代码示例,适合HR系统开发者与管理者参考,助力构建高效、可扩展的绩效管理体系。
|
10月前
|
SQL 关系型数据库 OLAP
云原生数据仓库AnalyticDB PostgreSQL同一个SQL可以实现向量索引、全文索引GIN、普通索引BTREE混合查询,简化业务实现逻辑、提升查询性能
本文档介绍了如何在AnalyticDB for PostgreSQL中创建表、向量索引及混合检索的实现步骤。主要内容包括:创建`articles`表并设置向量存储格式,创建ANN向量索引,为表增加`username`和`time`列,建立BTREE索引和GIN全文检索索引,并展示了查询结果。参考文档提供了详细的SQL语句和配置说明。
333 2
|
11月前
|
存储 监控 NoSQL
【赵渝强老师】MongoDB文档级别的并发控制
MongoDB使用WiredTiger存储引擎在文档级别进行并发控制,允许多个写操作同时修改不同文档,但对同一文档的修改需序列化执行。引擎采用乐观锁和意向锁机制处理冲突。通过视频讲解、插入大量文档示例及使用`mongotop`和`db.serverStatus()`命令,演示了如何监控MongoDB的锁信息和读写统计,展示了数据库和集合级别的写锁情况。
295 29
|
人工智能 数据可视化
用了这8款AI制作PPT软件,年终总结再也不是问题!
8款好用的AI生成PPT软件推荐,轻松解决你的年终总结!
|
机器学习/深度学习 自然语言处理 算法
基于python旅游景点满意度分析设计与实现
本文介绍了一个基于Python的情感分析系统,旨在通过CNN算法、LDA主题模型和jieba分词等自然语言处理技术,对海口市旅游景点的网络评论进行满意度分析,以客观评估和提升游客体验及景点服务质量。
563 1