- nebula 版本:3.0.0
- 部署方式:单机
- 安装方式:RPM
由于业务原因,把时间戳打到了边的rank上了
最开始尝试的是
find shortest path from "v1" to "v2" over e1,e2 where rank(edge)==1640966400000 yield path as p;
可以得到预期的路径结果,但find path 两端查的点多了之后,查询时间增加的很明显,然后尝试match用固定模式匹配
match p=(v)-[e:e1 | e2]-(v2) where id(v) in ["v1"] and id(v) in ["v2"] and rank(e)==1640966400000 return p;
发现这种方式不能有效的过滤边的rank
最后尝试了非路径的match
match (v)-[e:e1 | e2]-(v2) where id(v) in ["v1"] and id(v) in ["v2"] and rank(e)==1640966400000 return v1,v2,e;
这种和文档描述一致,可以正常过滤rank
match p=() 这种是由于什么考量没有加入rank过滤呢?
你好。历史原因,当初主要对照的opencypher 由于opencypher没有支持,所以设计时没有考虑这种情况。
1 个赞
好的,谢谢。在用match过滤边时把rank当作边的属性来看待是不是不合理呢?
我想是合理的,可能这种用法不太常见,opencypher没支持,nebula也没考虑到。
我也觉得是合理的,比如rank代表两个客户之间的转账时间,现在想查询某个时间段内这两个客户的转账记录,那用rank来过滤就是最好的。
wey
6
请问 @jmq2020 GetNeighbors
有可能做 rank filter 下推么?
-----+--------------+--------------+----------------+----------------------------------------------------------------------------------------------------
| 4 | Filter | 3 | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Filter_4" |
| | | | | } |
| | | | | inputVar: __GetNeighbors_3 |
| | | | | condition: (rank(EDGE)==1640966400000) |
| | | | | isStable: false |
-----+--------------+--------------+----------------+----------------------------------------------------------------------------------------------------
| 3 | GetNeighbors | 2 | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__GetNeighbors_3" |
| | | | | } |
| | | | | inputVar: __VAR_0 |
| | | | | space: 1 |
| | | | | dedup: true |
| | | | | limit: -1 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | src: COLUMN[0] |
| | | | | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | | vertexProps: |
| | | | | edgeProps: [ |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_type", |
| | | | | "_rank" |
| | | | | ], |
| | | | | "type": "4" |
| | | | | }, |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_type", |
| | | | | "_rank" |
| | | | | ], |
| | | | | "type": "5" |
| | | | | } |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
-----+--------------+--------------+----------------+——————————————————————————————————————————————————
(root@nebula) [nba]> profile go from "Tim Duncan" over * where like._rank == 1 yield edge as e
+---+
| e |
+---+
+---+
Empty set (time spent 3238/3706 us)
Execution Plan (optimize time 502 us)
-----+--------------+--------------+---------------------------------------------------------------------------------------------------------------------------+--------------------------
| id | name | dependencies | profiling data | operator info |
-----+--------------+--------------+---------------------------------------------------------------------------------------------------------------------------+--------------------------
| 3 | Project | 4 | ver: 0, rows: 0, execTime: 139us, totalTime: 150us | outputVar: { |
| | | | | "colNames": [ |
| | | | | "e" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_3" |
| | | | | } |
| | | | | inputVar: __Filter_2 |
| | | | | columns: [ |
| | | | | "EDGE AS e" |
| | | | | ] |
-----+--------------+--------------+---------------------------------------------------------------------------------------------------------------------------+--------------------------
| 4 | GetNeighbors | 0 | { | outputVar: { |
| | | | ver: 0, rows: 0, execTime: 159us, totalTime: 1586us | "colNames": [], |
| | | | storage_detail: {FilterNode:133(us),GetNeighborsNode:141(us),HashJoinNode:115(us),RelNode:141(us),SingleEdgeNode:106(us)} | "type": "DATASET", |
| | | | "192.168.8.6":24875 exec/total/vertices: 414(us)/1200(us)/1, | "name": "__Filter_2" |
| | | | total_rpc_time: 1406(us) | } |
| | | | } | inputVar: __VAR_0 |
| | | | | space: 7 |
| | | | | dedup: false |
| | | | | limit: -1 |
| | | | | filter: (like._rank==1) |
| | | | | orderBy: [] |
| | | | | src: COLUMN[0] |
| | | | | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | | vertexProps: |
| | | | | edgeProps: [ |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_rank", |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "likeness" |
| | | | | ], |
| | | | | "type": 11 |
| | | | | }, |
| | | | | { |
| | | | | "type": 12, |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_rank", |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "end_year", |
| | | | | "start_year" |
| | | | | ] |
| | | | | }, |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_rank", |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "end_year", |
| | | | | "start_year" |
| | | | | ], |
| | | | | "type": 13 |
| | | | | } |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
-----+--------------+--------------+---------------------------------------------------------------------------------------------------------------------------+--------------------------
| 0 | Start | | ver: 0, rows: 0, execTime: 1us, totalTime: 18us | outputVar: { |
| | | | | "colNames": [], |
| | | | | "name": "__Start_0", |
| | | | | "type": "DATASET" |
| | | | | } |
-----+--------------+--------------+---------------------------------------------------------------------------------------------------------------------------+--------------------------
rank 函数不能下推,但是rank作为属性可以下推
2 个赞
wey
8
原来如此
@jmq2020 太棒了!
@fiendoghx 你可以这么写 rank,这样 _rank filter会下推的。
e1._rank==1640966400000 or e2._rank== 1640966400000
find shortest path from "v1" to "v2" over e1,e2
where e1._rank==1640966400000 or e2._rank== 1640966400000 yield path as p;
(root@nebula) [basketballplayer]> find shortest path from "player101" to "team204" over * where serve._rank == 0 or follow._rank == 0 yield path as p;
+--------------------------------------------+
| p |
+--------------------------------------------+
| <("player101")-[:serve@0 {}]->("team204")> |
+--------------------------------------------+
Got 1 rows (time spent 4635/36411 us)
Tue, 07 Jun 2022 16:20:11 CST
(root@nebula) [basketballplayer]> explain find shortest path from "player101" to "team204" over * where serve._rank == 0 or follow._rank == 0 yield path as p;
Execution succeeded (time spent 1055/5675 us)
Execution Plan (optimize time 341 us)
-----+--------------+--------------+----------------+----------------------------------------------------------------------------------------------------
| 11 | GetNeighbors | 2 | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Filter_6" |
| | | | | } |
| | | | | inputVar: __VAR_1 |
| | | | | space: 2 |
| | | | | dedup: true |
| | | | | limit: -1 |
| | | | | filter: ((serve._rank==0) OR (follow._rank==0)) |
| | | | | orderBy: [] |
| | | | | src: COLUMN[0] |
| | | | | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | | vertexProps: |
| | | | | edgeProps: [ |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_rank", |
| | | | | "_type" |
| | | | | ], |
| | | | | "type": "-5" |
| | | | | }, |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_rank", |
| | | | | "_type" |
| | | | | ], |
| | | | | "type": "-6" |
| | | | | } |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
-----+--------------+--------------+----------------+----------------------------------------------------------------------------------------------------
…
2 个赞
system
关闭
10
此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。