如题
1 个赞
看起来逻辑、结果是等价的,蹲个开发者回答
(root@nebula) [basketballplayer]> go from "player100" over follow REVERSELY yield id($^), id($$) ,follow._src , follow._dst
+-------------+-------------+-------------+-------------+
| id($^) | id($$) | follow._src | follow._dst |
+-------------+-------------+-------------+-------------+
| "player100" | "player101" | "player100" | "player101" |
| "player100" | "player102" | "player100" | "player102" |
| "player100" | "player104" | "player100" | "player104" |
| "player100" | "player105" | "player100" | "player105" |
| "player100" | "player107" | "player100" | "player107" |
| "player100" | "player108" | "player100" | "player108" |
| "player100" | "player109" | "player100" | "player109" |
| "player100" | "player113" | "player100" | "player113" |
| "player100" | "player125" | "player100" | "player125" |
| "player100" | "player144" | "player100" | "player144" |
+-------------+-------------+-------------+-------------+
Got 10 rows (time spent 1572/185353 us)
Wed, 20 Jul 2022 10:32:11 CST
(root@nebula) [basketballplayer]> go from "player100" over follow yield id($^), id($$) ,follow._src , follow._dst
+-------------+-------------+-------------+-------------+
| id($^) | id($$) | follow._src | follow._dst |
+-------------+-------------+-------------+-------------+
| "player100" | "player101" | "player100" | "player101" |
| "player100" | "player125" | "player100" | "player125" |
+-------------+-------------+-------------+-------------+
Got 2 rows (time spent 1364/90797 us)
Wed, 20 Jul 2022 10:32:30 CST
(root@nebula) [basketballplayer]> explain go from "player100" over follow yield id($^)
Execution succeeded (time spent 2680/153326 us)
Execution Plan (optimize time 36 us)
-----+--------------+--------------+----------------+-------------------------------
| id | name | dependencies | profiling data | operator info |
-----+--------------+--------------+----------------+-------------------------------
| 2 | Project | 1 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "id($^)" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_2" |
| | | | | } |
| | | | | inputVar: __GetNeighbors_1 |
| | | | | columns: [ |
| | | | | "*._src" |
| | | | | ] |
-----+--------------+--------------+----------------+-------------------------------
| 1 | GetNeighbors | 0 | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__GetNeighbors_1" |
| | | | | } |
| | | | | inputVar: __VAR_0 |
| | | | | space: 2 |
| | | | | dedup: false |
| | | | | limit: -1 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | src: COLUMN[0] |
| | | | | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | | vertexProps: |
| | | | | edgeProps: [ |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_src" |
| | | | | ], |
| | | | | "type": "6" |
| | | | | } |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
-----+--------------+--------------+----------------+-------------------------------
| 0 | Start | | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Start_0" |
| | | | | } |
-----+--------------+--------------+----------------+-------------------------------
Wed, 20 Jul 2022 10:35:01 CST
(root@nebula) [basketballplayer]> explain go from "player100" over follow yield follow._src
Execution succeeded (time spent 325/115769 us)
Execution Plan (optimize time 35 us)
-----+--------------+--------------+----------------+-------------------------------
| id | name | dependencies | profiling data | operator info |
-----+--------------+--------------+----------------+-------------------------------
| 2 | Project | 1 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "follow._src" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_2" |
| | | | | } |
| | | | | inputVar: __GetNeighbors_1 |
| | | | | columns: [ |
| | | | | "follow._src" |
| | | | | ] |
-----+--------------+--------------+----------------+-------------------------------
| 1 | GetNeighbors | 0 | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__GetNeighbors_1" |
| | | | | } |
| | | | | inputVar: __VAR_0 |
| | | | | space: 2 |
| | | | | dedup: false |
| | | | | limit: -1 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | src: COLUMN[0] |
| | | | | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | | vertexProps: |
| | | | | edgeProps: [ |
| | | | | { |
| | | | | "props": [ |
| | | | | "_dst", |
| | | | | "_src" |
| | | | | ], |
| | | | | "type": "6" |
| | | | | } |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
-----+--------------+--------------+----------------+-------------------------------
| 0 | Start | | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Start_0" |
| | | | | } |
-----+--------------+--------------+----------------+-------------------------------
Wed, 20 Jul 2022 10:35:12 CST
(root@nebula) [basketballplayer]>
是的,我也是看结果觉得是等价,但是想确认一下底层逻辑。
请问 @jmq2020 这两个开销有什么区别么?看起来在双向上逻辑是完全一样的:都是 GO FROM 的点作为起点,无论方向。
性能上我理解是不是 id(xxx) 更贵一些,有一个函数调用,还是能优化成一样哈?
原来如此!
此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。