哈哈,好问题,你可以 explain 验证你的猜想呢,两者的计划是一样的。
(root@nebula) [basketballplayer]> explain LOOKUP ON player WHERE player.age > 22 YIELD properties(vertex).name AS name, properties(vertex).age AS age| YIELD $-.name, max($-.age) as max_age
Execution succeeded (time spent 1162/6728 us)
Execution Plan (optimize time 514 us)
-----+------------------+--------------+----------------+---------------------------------------
| id | name | dependencies | profiling data | operator info |
-----+------------------+--------------+----------------+---------------------------------------
| 4 | Aggregate | 3 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "$-.name", |
| | | | | "max_age" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Aggregate_4" |
| | | | | } |
| | | | | inputVar: __Project_3 |
| | | | | groupKeys: [ |
| | | | | "$-.name" |
| | | | | ] |
| | | | | groupItems: [ |
| | | | | { |
| | | | | "expr": "$-.name" |
| | | | | }, |
| | | | | { |
| | | | | "expr": "max($-.age)" |
| | | | | } |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 3 | Project | 2 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "name", |
| | | | | "age" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_3" |
| | | | | } |
| | | | | inputVar: __Filter_2 |
| | | | | columns: [ |
| | | | | "properties(VERTEX).name AS name", |
| | | | | "properties(VERTEX).age AS age" |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 2 | Filter | 5 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "_vid", |
| | | | | "player._tag", |
| | | | | "player.age", |
| | | | | "player.name" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Filter_2" |
| | | | | } |
| | | | | inputVar: __TagIndexFullScan_1 |
| | | | | condition: (player.age>22) |
| | | | | isStable: false |
-----+------------------+--------------+----------------+---------------------------------------
| 5 | TagIndexFullScan | 0 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "_vid", |
| | | | | "player._tag", |
| | | | | "player.age", |
| | | | | "player.name" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__TagIndexFullScan_1" |
| | | | | } |
| | | | | inputVar: |
| | | | | space: 49 |
| | | | | dedup: false |
| | | | | limit: 9223372036854775807 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | schemaId: 50 |
| | | | | isEdge: false |
| | | | | returnCols: [ |
| | | | | "_vid", |
| | | | | "_tag", |
| | | | | "age", |
| | | | | "name" |
| | | | | ] |
| | | | | indexCtx: [ |
| | | | | { |
| | | | | "columnHints": [], |
| | | | | "filter": "", |
| | | | | "index_id": 54 |
| | | | | } |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 0 | Start | | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Start_0" |
| | | | | } |
-----+------------------+--------------+----------------+---------------------------------------
Tue, 11 Oct 2022 11:41:43 CST
(root@nebula) [basketballplayer]> explain LOOKUP ON player WHERE player.age > 22 YIELD properties(vertex).name AS name, properties(vertex).age AS age| GROUP BY $-.name YIELD $-.name, max($-.age) as max_age
Execution succeeded (time spent 1158/14940 us)
Execution Plan (optimize time 510 us)
-----+------------------+--------------+----------------+---------------------------------------
| id | name | dependencies | profiling data | operator info |
-----+------------------+--------------+----------------+---------------------------------------
| 4 | Aggregate | 3 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "$-.name", |
| | | | | "max_age" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Aggregate_4" |
| | | | | } |
| | | | | inputVar: __Project_3 |
| | | | | groupKeys: [ |
| | | | | "$-.name" |
| | | | | ] |
| | | | | groupItems: [ |
| | | | | { |
| | | | | "expr": "$-.name" |
| | | | | }, |
| | | | | { |
| | | | | "expr": "max($-.age)" |
| | | | | } |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 3 | Project | 2 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "name", |
| | | | | "age" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_3" |
| | | | | } |
| | | | | inputVar: __Filter_2 |
| | | | | columns: [ |
| | | | | "properties(VERTEX).name AS name", |
| | | | | "properties(VERTEX).age AS age" |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 2 | Filter | 5 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "_vid", |
| | | | | "player._tag", |
| | | | | "player.age", |
| | | | | "player.name" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Filter_2" |
| | | | | } |
| | | | | inputVar: __TagIndexFullScan_1 |
| | | | | condition: (player.age>22) |
| | | | | isStable: false |
-----+------------------+--------------+----------------+---------------------------------------
| 5 | TagIndexFullScan | 0 | | outputVar: { |
| | | | | "colNames": [ |
| | | | | "_vid", |
| | | | | "player._tag", |
| | | | | "player.age", |
| | | | | "player.name" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__TagIndexFullScan_1" |
| | | | | } |
| | | | | inputVar: |
| | | | | space: 49 |
| | | | | dedup: false |
| | | | | limit: 9223372036854775807 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | schemaId: 50 |
| | | | | isEdge: false |
| | | | | returnCols: [ |
| | | | | "_vid", |
| | | | | "_tag", |
| | | | | "age", |
| | | | | "name" |
| | | | | ] |
| | | | | indexCtx: [ |
| | | | | { |
| | | | | "columnHints": [], |
| | | | | "filter": "", |
| | | | | "index_id": 54 |
| | | | | } |
| | | | | ] |
-----+------------------+--------------+----------------+---------------------------------------
| 0 | Start | | | outputVar: { |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Start_0" |
| | | | | } |
-----+------------------+--------------+----------------+---------------------------------------
Tue, 11 Oct 2022 11:42:11 CST