如何用PolarDB-PG开源实现50亿图谱数据量的N度搜索、最短路径搜索:
https://github.com/digoal/blog/blob/master/201801/20180102_04.md
递归语法:
造数据:
create table a(
c1 int, -- 点1
c2 int, -- 点2
prop jsonb, -- 点1,2对应的边的属性,使用JSON存储,包括权重,关系等等。
primary key (c1,c2) -- 主键
);
create index idx_a_2 on a(c1, COALESCE(((prop ->> 'weight'::text))::float8, 0));
vi test.sql
\set id random(1,10000000)
insert into a select :id, ((width_bucket(:id,1,10000000,2000)-1)*50000 + (random()*50000)::int) from generate_series(1,1000) on conflict (c1,c2) do nothing;
pgbench -M prepared -n -r -P 5 -f ./test.sql -c 50 -j 50 -t 100000
N度搜索:
最短路径:
欢迎关注PolarDB公众号:
更多进阶学习关注:
1.PG手册: https://www.postgresql.org/docs/current/index.html
2.PG开源项目: https://git.postgresql.org/gitweb/?p=postgresql.git;a=summary
3.PolarDB-PG手册: https://apsaradb.github.io/PolarDB-for-PostgreSQL/
4.PolarDB-PG开源项目: https://github.com/ApsaraDB/PolarDB-for-PostgreSQL
5.PolarDB-X手册: https://doc.polardbx.com/
6.PolarDB-X开源项目: https://github.com/polardb/polardbx-sql
7.PolarDB-X知乎官方号: https://www.zhihu.com/org/polardb-x
8.PolarDB 开源社区B站视频号: https://space.bilibili.com/2070322174
9.PolarDB 高手课: https://developer.aliyun.com/learning/course/1258
10.PolarDB-PG 内核从入门到精通: https://developer.aliyun.com/learning/topic/database
11.PolarDB 开源学习图谱: https://www.aliyun.com/database/openpolardb/activity
12.免费动手实验: https://developer.aliyun.com/adc/
13.免费云资源: https://click.aliyun.com/m/1000371820/
14.其他资料:
https://www.interdb.jp/pg/index.html