暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

PolarDB 小知识: 递归的实验, 50亿图谱数据量的N度搜索、最短路径搜索

原创 手机用户6813 2023-06-13
717

如何用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

https://postgrespro.com/community/books/internals

https://github.com/digoal/blog/blob/master/README.md

最后修改时间:2023-06-13 11:31:51
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论