MATCH语句匹配边无法查询出语句

  执行MATCH语句,发现没有返回边数据

  • profile结果
(root@nebula) [quanxi_ids]> profile MATCH ()-[e]->() RETURN e LIMIT 3;
+---+
| e |
+---+
+---+
Empty set (time spent 1.692ms/8.095189ms)

Execution Plan (optimize time 198 us)

-----+----------------+--------------+--------------------------+---------------------------------
| id | name           | dependencies | profiling data           | operator info                  |
-----+----------------+--------------+--------------------------+---------------------------------
| 11 | Project        | 10           | {                        | outputVar: {                   |
|    |                |              |   "execTime": "6(us)",   |   "colNames": [                |
|    |                |              |   "rows": 0,             |     "e"                        |
|    |                |              |   "totalTime": "7(us)",  |   ],                           |
|    |                |              |   "version": 0           |   "type": "DATASET",           |
|    |                |              | }                        |   "name": "__Limit_8"          |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar: __Limit_10           |
|    |                |              |                          | columns: [                     |
|    |                |              |                          |   "$-.e[0] AS e"               |
|    |                |              |                          | ]                              |
-----+----------------+--------------+--------------------------+---------------------------------
| 10 | Limit          | 5            | {                        | outputVar: {                   |
|    |                |              |   "execTime": "4(us)",   |   "colNames": [                |
|    |                |              |   "rows": 0,             |     "__VAR_0",                 |
|    |                |              |   "totalTime": "6(us)",  |     "e",                       |
|    |                |              |   "version": 0           |     "__VAR_1"                  |
|    |                |              | }                        |   ],                           |
|    |                |              |                          |   "type": "DATASET",           |
|    |                |              |                          |   "name": "__Limit_10"         |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar: __AppendVertices_5   |
|    |                |              |                          | offset: 0                      |
|    |                |              |                          | count: 3                       |
-----+----------------+--------------+--------------------------+---------------------------------
|  5 | AppendVertices | 4            | {                        | outputVar: {                   |
|    |                |              |   "execTime": "6(us)",   |   "colNames": [                |
|    |                |              |   "rows": 0,             |     "__VAR_0",                 |
|    |                |              |   "totalTime": "7(us)",  |     "e",                       |
|    |                |              |   "version": 0           |     "__VAR_1"                  |
|    |                |              | }                        |   ],                           |
|    |                |              |                          |   "type": "DATASET",           |
|    |                |              |                          |   "name": "__AppendVertices_5" |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar: __Traverse_4         |
|    |                |              |                          | space: 10                      |
|    |                |              |                          | dedup: true                    |
|    |                |              |                          | limit: -1                      |
|    |                |              |                          | filter:                        |
|    |                |              |                          | orderBy: []                    |
|    |                |              |                          | src: none_direct_dst($-.e)     |
|    |                |              |                          | props: [                       |
|    |                |              |                          |   {                            |
|    |                |              |                          |     "props": [                 |
|    |                |              |                          |       "_tag"                   |
|    |                |              |                          |     ],                         |
|    |                |              |                          |     "tagId": 11                |
|    |                |              |                          |   },                           |
|    |                |              |                          |   {                            |
|    |                |              |                          |     "props": [                 |
|    |                |              |                          |       "_tag"                   |
|    |                |              |                          |     ],                         |
|    |                |              |                          |     "tagId": 14                |
|    |                |              |                          |   }                            |
|    |                |              |                          | ]                              |
|    |                |              |                          | exprs:                         |
|    |                |              |                          | vertex_filter:                 |
|    |                |              |                          | if_track_previous_path: true   |
-----+----------------+--------------+--------------------------+---------------------------------
|  4 | Traverse       | 2            | {                        | outputVar: {                   |
|    |                |              |   "execTime": "2(us)",   |   "colNames": [                |
|    |                |              |   "rows": 0,             |     "__VAR_0",                 |
|    |                |              |   "totalTime": "13(us)", |     "e"                        |
|    |                |              |   "version": 0           |   ],                           |
|    |                |              | }                        |   "type": "DATASET",           |
|    |                |              |                          |   "name": "__Traverse_4"       |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar: __Dedup_2            |
|    |                |              |                          | space: 10                      |
|    |                |              |                          | dedup: true                    |
|    |                |              |                          | limit: -1                      |
|    |                |              |                          | filter:                        |
|    |                |              |                          | orderBy: []                    |
|    |                |              |                          | src: $_vid                     |
|    |                |              |                          | edgeTypes: []                  |
|    |                |              |                          | edgeDirection: OUT_EDGE        |
|    |                |              |                          | vertexProps:                   |
|    |                |              |                          | edgeProps: [                   |
|    |                |              |                          |   {                            |
|    |                |              |                          |     "props": [                 |
|    |                |              |                          |       "_src",                  |
|    |                |              |                          |       "_type",                 |
|    |                |              |                          |       "_rank",                 |
|    |                |              |                          |       "_dst",                  |
|    |                |              |                          |       "name",                  |
|    |                |              |                          |       "proto",                 |
|    |                |              |                          |       "app_proto",             |
|    |                |              |                          |       "tool",                  |
|    |                |              |                          |       "attacker_port",         |
|    |                |              |                          |       "victim_port",           |
|    |                |              |                          |       "phase",                 |
|    |                |              |                          |       "result",                |
|    |                |              |                          |       "tag",                   |
|    |                |              |                          |       "severity",              |
|    |                |              |                          |       "event_time",            |
|    |                |              |                          |       "flow_id"                |
|    |                |              |                          |     ],                         |
|    |                |              |                          |     "type": 12                 |
|    |                |              |                          |   }                            |
|    |                |              |                          | ]                              |
|    |                |              |                          | statProps:                     |
|    |                |              |                          | exprs:                         |
|    |                |              |                          | random: false                  |
|    |                |              |                          | steps:                         |
|    |                |              |                          | vertex filter:                 |
|    |                |              |                          | edge filter:                   |
|    |                |              |                          | if_track_previous_path: false  |
|    |                |              |                          | first step filter:             |
-----+----------------+--------------+--------------------------+---------------------------------
|  2 | Dedup          | 1            | {                        | outputVar: {                   |
|    |                |              |   "execTime": "6(us)",   |   "colNames": [                |
|    |                |              |   "rows": 0,             |     "_vid"                     |
|    |                |              |   "totalTime": "7(us)",  |   ],                           |
|    |                |              |   "version": 0           |   "type": "DATASET",           |
|    |                |              | }                        |   "name": "__Dedup_2"          |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar: __IndexScan_1        |
-----+----------------+--------------+--------------------------+---------------------------------
|  1 | IndexScan      | 3            |                          | outputVar: {                   |
|    |                |              |                          |   "colNames": [                |
|    |                |              |                          |     "_vid"                     |
|    |                |              |                          |   ],                           |
|    |                |              |                          |   "type": "DATASET",           |
|    |                |              |                          |   "name": "__IndexScan_1"      |
|    |                |              |                          | }                              |
|    |                |              |                          | inputVar:                      |
|    |                |              |                          | space: 10                      |
|    |                |              |                          | dedup: false                   |
|    |                |              |                          | limit: 9223372036854775807     |
|    |                |              |                          | filter:                        |
|    |                |              |                          | orderBy: []                    |
|    |                |              |                          | schemaId: 12                   |
|    |                |              |                          | isEdge: true                   |
|    |                |              |                          | returnCols: [                  |
|    |                |              |                          |   "_src"                       |
|    |                |              |                          | ]                              |
|    |                |              |                          | indexCtx: [                    |
|    |                |              |                          |   {                            |
|    |                |              |                          |     "columnHints": [],         |
|    |                |              |                          |     "filter": "",              |
|    |                |              |                          |     "index_id": 13             |
|    |                |              |                          |   }                            |
|    |                |              |                          | ]                              |
-----+----------------+--------------+--------------------------+---------------------------------
|  3 | Start          |              | {                        | outputVar: {                   |
|    |                |              |   "execTime": "0(us)",   |   "colNames": [],              |
|    |                |              |   "rows": 0,             |   "type": "DATASET",           |
|    |                |              |   "totalTime": "18(us)", |   "name": "__Start_3"          |
|    |                |              |   "version": 0           | }                              |
|    |                |              | }                        |                                |
-----+----------------+--------------+--------------------------+---------------------------------

Thu, 09 Feb 2023 07:38:16 UTC

企业版吗?

不是的

这个执行计划我不是很看得懂,而且我印象中也从来没有实现过这样的代码。我用的同样的包执行计划却和你的不一样。

这个 profile 没有发错吧?(居然没有行数信息 :melting_face:

从你发的执行计划上看 这个 id 为 13 的 index 比较可疑,可以尝试 rebuild 一下。
也可以测试一下指定不同 edge type 的情况:

MATCH ()-[e:E1]->() RETURN e limit 3
MATCH ()-[e:E2]->() RETURN e limit 3

profile的结果应该是没错的

在我重建索引之后可以查询出结果了,请问这是为什么呢

索引在创建之后需要 rebuild 才能生效,否则可能会产生类似上面的情况(无结果或返回部分结果)。

1 个赞