Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization: with id(n) filter should be passthrough with start_vid #5667

Open
wey-gu opened this issue Aug 9, 2023 · 0 comments
Open

optimization: with id(n) filter should be passthrough with start_vid #5667

wey-gu opened this issue Aug 9, 2023 · 0 comments
Labels
type/enhancement Type: make the code neat or more efficient

Comments

@wey-gu
Copy link
Contributor

wey-gu commented Aug 9, 2023

Now it's actually scanning all data for the second MATCH, this is being used now in text2cypher to get schema.

(root@nebula) [basketballplayer]> profile 
MATCH ()-[e:follow]->() 
  WITH e limit 1 
MATCH (m)-[e:follow]->(n) 
  WHERE id(m) == src(e) AND id(n) == dst(e)
RETURN "(:" + tags(m)[0] + ")-[:follow]->(:" + tags(n)[0] + ")" AS rels

+----------------------------------+
| rels                             |
+----------------------------------+
| "(:player)-[:follow]->(:player)" |
+----------------------------------+
Got 1 rows (time spent 15.983ms/21.262208ms)

Execution Plan (optimize time 2529 us)

-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| id | name           | dependencies | profiling data                            | operator info                                                                |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 17 | Project        | 21           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "20(us)",                   |   "colNames": [                                                              |
|    |                |              |   "rows": 1,                              |     "rels"                                                                   |
|    |                |              |   "totalTime": "22(us)",                  |   ],                                                                         |
|    |                |              |   "version": 0                            |   "type": "DATASET",                                                         |
|    |                |              | }                                         |   "name": "__Project_17"                                                     |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __Filter_16                                                        |
|    |                |              |                                           | columns: [                                                                   |
|    |                |              |                                           |   "((((\"(:\"+tags($m)[0])+\")-[:follow]->(:\")+tags($n)[0])+\")\") AS rels" |
|    |                |              |                                           | ]                                                                            |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 21 | HashInnerJoin  | 26,32        | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "110(us)",                  |   "colNames": [                                                              |
|    |                |              |   "rows": 1,                              |     "e",                                                                     |
|    |                |              |   "totalTime": "114(us)",                 |     "m",                                                                     |
|    |                |              |   "version": 0                            |     "n"                                                                      |
|    |                |              | }                                         |   ],                                                                         |
|    |                |              |                                           |   "type": "DATASET",                                                         |
|    |                |              |                                           |   "name": "__Filter_16"                                                      |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: {                                                                  |
|    |                |              |                                           |   "rightVar": "__Project_14",                                                |
|    |                |              |                                           |   "leftVar": "__Limit_8"                                                     |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | hashKeys: [                                                                  |
|    |                |              |                                           |   "_joinkey($-.e)"                                                           |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | probeKeys: [                                                                 |
|    |                |              |                                           |   "_joinkey($-.e)"                                                           |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | kind: InnerJoin                                                              |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 26 | Project        | 27           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "30(us)",                   |   "colNames": [                                                              |
|    |                |              |   "rows": 1,                              |     "e"                                                                      |
|    |                |              |   "totalTime": "36(us)",                  |   ],                                                                         |
|    |                |              |   "version": 0                            |   "type": "DATASET",                                                         |
|    |                |              | }                                         |   "name": "__Limit_8"                                                        |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __Limit_27                                                         |
|    |                |              |                                           | columns: [                                                                   |
|    |                |              |                                           |   "$-.e[0] AS e"                                                             |
|    |                |              |                                           | ]                                                                            |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 27 | Limit          | 28           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "12(us)",                   |   "colNames": [                                                              |
|    |                |              |   "rows": 1,                              |     "__VAR_0",                                                               |
|    |                |              |   "totalTime": "17(us)",                  |     "e",                                                                     |
|    |                |              |   "version": 0                            |     "__VAR_1"                                                                |
|    |                |              | }                                         |   ],                                                                         |
|    |                |              |                                           |   "type": "DATASET",                                                         |
|    |                |              |                                           |   "name": "__Limit_27"                                                       |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __AppendVertices_28                                                |
|    |                |              |                                           | offset: 0                                                                    |
|    |                |              |                                           | count: 1                                                                     |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 28 | AppendVertices | 30           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "277(us)",                  |   "colNames": [                                                              |
|    |                |              |   "resp[0]": {                            |     "e",                                                                     |
|    |                |              |     "exec": "611(us)",                    |     "__VAR_1"                                                                |
|    |                |              |     "host": "storaged0:9779",             |   ],                                                                         |
|    |                |              |     "total": "1479(us)"                   |   "type": "DATASET",                                                         |
|    |                |              |   },                                      |   "name": "__AppendVertices_28"                                              |
|    |                |              |   "rows": 10,                             | }                                                                            |
|    |                |              |   "totalTime": "1924(us)",                | inputVar: __Project_30                                                       |
|    |                |              |   "total_rpc": "1759(us)",                | space: 2                                                                     |
|    |                |              |   "version": 0                            | dedup: true                                                                  |
|    |                |              | }                                         | limit: -1                                                                    |
|    |                |              |                                           | filter:                                                                      |
|    |                |              |                                           | orderBy: []                                                                  |
|    |                |              |                                           | src: none_direct_dst($-.e,$-.__VAR_0)                                        |
|    |                |              |                                           | props: [                                                                     |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 3                                                               |
|    |                |              |                                           |   },                                                                         |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 4                                                               |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | exprs:                                                                       |
|    |                |              |                                           | vertex_filter:                                                               |
|    |                |              |                                           | if_track_previous_path: true                                                 |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 30 | Project        | 29           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "80(us)",                   |   "colNames": [                                                              |
|    |                |              |   "rows": 10,                             |     "e"                                                                      |
|    |                |              |   "totalTime": "85(us)",                  |   ],                                                                         |
|    |                |              |   "version": 0                            |   "type": "DATASET",                                                         |
|    |                |              | }                                         |   "name": "__Project_30"                                                     |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __ScanEdges_29                                                     |
|    |                |              |                                           | columns: [                                                                   |
|    |                |              |                                           |   "[EDGE] AS e"                                                              |
|    |                |              |                                           | ]                                                                            |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 29 | ScanEdges      | 3            | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "173(us)",                  |   "colNames": [                                                              |
|    |                |              |   "resp[0]": {                            |     "e"                                                                      |
|    |                |              |     "exec": "818(us)",                    |   ],                                                                         |
|    |                |              |     "host": "storaged0:9779",             |   "type": "DATASET",                                                         |
|    |                |              |     "total": "2004(us)"                   |   "name": "__ScanEdges_29"                                                   |
|    |                |              |   },                                      | }                                                                            |
|    |                |              |   "rows": 10,                             | inputVar:                                                                    |
|    |                |              |   "totalTime": "2237(us)",                | space: 2                                                                     |
|    |                |              |   "total_rpc": "2128(us)",                | dedup: true                                                                  |
|    |                |              |   "version": 0                            | limit: 1                                                                     |
|    |                |              | }                                         | filter:                                                                      |
|    |                |              |                                           | orderBy: []                                                                  |
|    |                |              |                                           | props: [                                                                     |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_src",                                                                |
|    |                |              |                                           |       "_dst",                                                                |
|    |                |              |                                           |       "_type",                                                               |
|    |                |              |                                           |       "_rank"                                                                |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "type": 6                                                                |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | exprs:                                                                       |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
|  3 | Start          |              | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "0(us)",                    |   "colNames": [],                                                            |
|    |                |              |   "rows": 0,                              |   "type": "DATASET",                                                         |
|    |                |              |   "totalTime": "75(us)",                  |   "name": "__Start_3"                                                        |
|    |                |              |   "version": 0                            | }                                                                            |
|    |                |              | }                                         |                                                                              |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 32 | Project        | 35           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "125(us)",                  |   "colNames": [                                                              |
|    |                |              |   "rows": 81,                             |     "m",                                                                     |
|    |                |              |   "totalTime": "127(us)",                 |     "e",                                                                     |
|    |                |              |   "version": 0                            |     "n"                                                                      |
|    |                |              | }                                         |   ],                                                                         |
|    |                |              |                                           |   "type": "DATASET",                                                         |
|    |                |              |                                           |   "name": "__Project_14"                                                     |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __Filter_31                                                        |
|    |                |              |                                           | columns: [                                                                   |
|    |                |              |                                           |   "$-.m AS m",                                                               |
|    |                |              |                                           |   "$-.e[0] AS e",                                                            |
|    |                |              |                                           |   "$-.n AS n"                                                                |
|    |                |              |                                           | ]                                                                            |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 35 | Filter         | 34           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "131(us)",                  |   "colNames": [                                                              |
|    |                |              |   "rows": 81,                             |     "m",                                                                     |
|    |                |              |   "totalTime": "137(us)",                 |     "e",                                                                     |
|    |                |              |   "version": 0                            |     "n"                                                                      |
|    |                |              | }                                         |   ],                                                                         |
|    |                |              |                                           |   "type": "DATASET",                                                         |
|    |                |              |                                           |   "name": "__Filter_31"                                                      |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __AppendVertices_34                                                |
|    |                |              |                                           | condition: (id($-.n)==dst($-.e[0]))                                          |
|    |                |              |                                           | isStable: false                                                              |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 34 | AppendVertices | 33           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "546(us)",                  |   "colNames": [                                                              |
|    |                |              |   "resp[0]": {                            |     "m",                                                                     |
|    |                |              |     "exec": "607(us)",                    |     "e",                                                                     |
|    |                |              |     "host": "storaged0:9779",             |     "n"                                                                      |
|    |                |              |     "total": "1674(us)"                   |   ],                                                                         |
|    |                |              |   },                                      |   "type": "DATASET",                                                         |
|    |                |              |   "rows": 81,                             |   "name": "__AppendVertices_34"                                              |
|    |                |              |   "totalTime": "2181(us)",                | }                                                                            |
|    |                |              |   "total_rpc": "1824(us)",                | inputVar: __Filter_33                                                        |
|    |                |              |   "version": 0                            | space: 2                                                                     |
|    |                |              | }                                         | dedup: true                                                                  |
|    |                |              |                                           | limit: -1                                                                    |
|    |                |              |                                           | filter:                                                                      |
|    |                |              |                                           | orderBy: []                                                                  |
|    |                |              |                                           | src: none_direct_dst($-.e,$-.m)                                              |
|    |                |              |                                           | props: [                                                                     |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "name",                                                                |
|    |                |              |                                           |       "age",                                                                 |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 3                                                               |
|    |                |              |                                           |   },                                                                         |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "name",                                                                |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 4                                                               |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | exprs:                                                                       |
|    |                |              |                                           | vertex_filter:                                                               |
|    |                |              |                                           | if_track_previous_path: true                                                 |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 33 | Filter         | 12           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "108(us)",                  |   "colNames": [                                                              |
|    |                |              |   "rows": 81,                             |     "m",                                                                     |
|    |                |              |   "totalTime": "114(us)",                 |     "e"                                                                      |
|    |                |              |   "version": 0                            |   ],                                                                         |
|    |                |              | }                                         |   "type": "DATASET",                                                         |
|    |                |              |                                           |   "name": "__Filter_33"                                                      |
|    |                |              |                                           | }                                                                            |
|    |                |              |                                           | inputVar: __Traverse_12                                                      |
|    |                |              |                                           | condition: (id($-.m)==src($-.e[0]))                                          |
|    |                |              |                                           | isStable: false                                                              |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 12 | Traverse       | 23           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "140(us)",                  |   "colNames": [                                                              |
|    |                |              |   "expandPostTaskTime": "57(us)",         |     "m",                                                                     |
|    |                |              |   "expandTaskRunTime": [                  |     "e"                                                                      |
|    |                |              |     461                                   |   ],                                                                         |
|    |                |              |   ],                                      |   "type": "DATASET",                                                         |
|    |                |              |   "expandTime": "707(us)",                |   "name": "__Traverse_12"                                                    |
|    |                |              |   "rows": 81,                             | }                                                                            |
|    |                |              |   "step[1]": {                            | inputVar: __Filter_10                                                        |
|    |                |              |     "storage": [                          | space: 2                                                                     |
|    |                |              |       {                                   | dedup: true                                                                  |
|    |                |              |         "exec": "1235(us)",               | limit: -1                                                                    |
|    |                |              |         "host": "storaged0:9779",         | filter:                                                                      |
|    |                |              |         "storage_detail": {               | orderBy: []                                                                  |
|    |                |              |           "GetNeighborsNode": "4366(us)", | src: $-._vid                                                                 |
|    |                |              |           "HashJoinNode": "3916(us)",     | edgeTypes: []                                                                |
|    |                |              |           "RelNode": "4390(us)",          | edgeDirection: OUT_EDGE                                                      |
|    |                |              |           "SingleEdgeNode": "2842(us)",   | vertexProps: [                                                               |
|    |                |              |           "TagNode": "742(us)"            |   {                                                                          |
|    |                |              |         },                                |     "props": [                                                               |
|    |                |              |         "total": "2922(us)",              |       "name",                                                                |
|    |                |              |         "vertices": 81                    |       "age",                                                                 |
|    |                |              |       }                                   |       "_tag"                                                                 |
|    |                |              |     ],                                    |     ],                                                                       |
|    |                |              |     "total_rpc_time": "3222(us)"          |     "tagId": 3                                                               |
|    |                |              |   },                                      |   },                                                                         |
|    |                |              |   "totalTime": "4252(us)",                |   {                                                                          |
|    |                |              |   "version": 0                            |     "props": [                                                               |
|    |                |              | }                                         |       "name",                                                                |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 4                                                               |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | edgeProps: [                                                                 |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_dst",                                                                |
|    |                |              |                                           |       "_type",                                                               |
|    |                |              |                                           |       "_rank"                                                                |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "type": 6                                                                |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | statProps:                                                                   |
|    |                |              |                                           | exprs:                                                                       |
|    |                |              |                                           | random: false                                                                |
|    |                |              |                                           | steps: 1..1                                                                  |
|    |                |              |                                           | vertex filter:                                                               |
|    |                |              |                                           | edge filter:                                                                 |
|    |                |              |                                           | if_track_previous_path: false                                                |
|    |                |              |                                           | first step filter:                                                           |
|    |                |              |                                           | tag filter:                                                                  |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 23 | ScanVertices   | 11           | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "273(us)",                  |   "colNames": [                                                              |
|    |                |              |   "resp[0]": {                            |     "_vid",                                                                  |
|    |                |              |     "exec": "2251(us)",                   |     "team._tag",                                                             |
|    |                |              |     "host": "storaged0:9779",             |     "player._tag"                                                            |
|    |                |              |     "total": "3437(us)"                   |   ],                                                                         |
|    |                |              |   },                                      |   "type": "DATASET",                                                         |
|    |                |              |   "rows": 81,                             |   "name": "__Filter_10"                                                      |
|    |                |              |   "totalTime": "4690(us)",                | }                                                                            |
|    |                |              |   "total_rpc": "4533(us)",                | inputVar:                                                                    |
|    |                |              |   "version": 0                            | space: 2                                                                     |
|    |                |              | }                                         | dedup: false                                                                 |
|    |                |              |                                           | limit: -1                                                                    |
|    |                |              |                                           | filter: (team._tag IS NOT EMPTY OR player._tag IS NOT EMPTY)                 |
|    |                |              |                                           | orderBy: []                                                                  |
|    |                |              |                                           | props: [                                                                     |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 4                                                               |
|    |                |              |                                           |   },                                                                         |
|    |                |              |                                           |   {                                                                          |
|    |                |              |                                           |     "props": [                                                               |
|    |                |              |                                           |       "_tag"                                                                 |
|    |                |              |                                           |     ],                                                                       |
|    |                |              |                                           |     "tagId": 3                                                               |
|    |                |              |                                           |   }                                                                          |
|    |                |              |                                           | ]                                                                            |
|    |                |              |                                           | exprs:                                                                       |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
| 11 | Start          |              | {                                         | outputVar: {                                                                 |
|    |                |              |   "execTime": "0(us)",                    |   "colNames": [],                                                            |
|    |                |              |   "rows": 0,                              |   "type": "DATASET",                                                         |
|    |                |              |   "totalTime": "82(us)",                  |   "name": "__Start_11"                                                       |
|    |                |              |   "version": 0                            | }                                                                            |
|    |                |              | }                                         |                                                                              |
-----+----------------+--------------+-------------------------------------------+-------------------------------------------------------------------------------
@wey-gu wey-gu added the type/enhancement Type: make the code neat or more efficient label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

No branches or pull requests

1 participant