YaeSakuraQ opened a new issue, #3480: URL: https://github.com/apache/hugegraph/issues/3480
### Bug Type (问题类型) performance (性能下降) ### Before submit - [x] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents) ### Environment (环境信息) - Server version: Apache HugeGraph 1.7.0 - Backend: RocksDB, single server - Deployment: `hugegraph/hugegraph:1.7.0` in Docker on macOS ARM64, with 2 CPUs and a 3 GiB memory limit - Query interface: Gremlin-Groovy over the Gremlin HTTP endpoint, GraphSON 3, default traversal strategies - Data size: 100,100 vertices and 100,150 edges ### Expected & Actual behavior (期望与实际表现) 1. **How to reproduce** Run the native Gremlin-Groovy setup in **Vertex/Edge example** in an empty graph with a fresh schema. Each of the 50 start vertices has one outgoing `Pattern_p_low_edge` and 2,000 outgoing `Pattern_p_high_edge` edges. All targets have `keep=true`, so the first neighbor on either label is enough for `not()` to reject the start vertex. 2. **Actual behavior** Both traversals return `[]`. Median runtime was **1.80 ms** for q1 and **17.49 ms** for q2. The median runtimes differ by **9.73×**. The `profile()` excerpt shows the predicate folded into the child step in both queries: ```text q1 NotStep([HugeVertexStep(OUT,[Pattern_p_low_edge],Vertex,[keep.eq(true)])]) q2 NotStep([HugeVertexStep(OUT,[Pattern_p_high_edge],Vertex,[keep.eq(true)])]) ``` The child step reports no adjacency-read count in either profile. The timing difference is observable on this graph. The profiles leave open how many adjacency entries HugeGraph reads and where that work occurs. 3. **Expected behavior** The existence check should be able to reject each start vertex as soon as it finds one qualifying neighbor. Please investigate whether the work in `HugeVertexStep` under `NotStep` can be limited to what is needed to establish that match. ### Vertex/Edge example (问题点 / 边数据举例) ```javascript //Run this setup in an empty HugeGraph graph with a fresh schema. Bind the graph's traversal source to `g`. In GraphSpace `DEFAULT` for graph `hugegraph`, the Gremlin HTTP alias is `{"g":"__g_DEFAULT-hugegraph"}`. def graph = g.getGraph() def s = graph.schema() s.propertyKey('uid').asLong().valueSingle().create() s.propertyKey('keep').asBoolean().valueSingle().create() s.propertyKey('value').asLong().valueSingle().create() s.propertyKey('p_gate_true').asBoolean().valueSingle().create() s.propertyKey('p_gate_false').asBoolean().valueSingle().create() s.propertyKey('p_anchor').asLong().valueSingle().create() s.propertyKey('property_float').asDouble().valueSingle().create() s.propertyKey('_gsp_eid').asLong().valueSingle().create() s.vertexLabel('Pattern_p_high').useAutomaticId() .properties(*['uid', 'keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']) .nullableKeys(*['keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']).enableLabelIndex(true).create() s.vertexLabel('Pattern_p_low').useAutomaticId() .properties(*['uid', 'keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']) .nullableKeys(*['keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']).enableLabelIndex(true).create() s.vertexLabel('Pattern_p_witness').useAutomaticId() .properties(*['uid', 'keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']) .nullableKeys(*['keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']).enableLabelIndex(true).create() s.vertexLabel('Random_label_1').useAutomaticId() .properties(*['uid', 'keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']) .nullableKeys(*['keep', 'value', 'p_gate_true', 'p_gate_false', 'p_anchor', 'property_float']).enableLabelIndex(true).create() s.edgeLabel('Pattern_p_high_edge').asBase().properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']) .multiTimes().sortKeys('_gsp_eid').enableLabelIndex(true).create() s.edgeLabel('Pattern_p_high_edge__0').withBase('Pattern_p_high_edge').link('Random_label_1', 'Pattern_p_high') .properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']).multiTimes().sortKeys('_gsp_eid') .enableLabelIndex(true).create() s.edgeLabel('Pattern_p_low_edge').asBase().properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']) .multiTimes().sortKeys('_gsp_eid').enableLabelIndex(true).create() s.edgeLabel('Pattern_p_low_edge__0').withBase('Pattern_p_low_edge').link('Random_label_1', 'Pattern_p_low') .properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']).multiTimes().sortKeys('_gsp_eid') .enableLabelIndex(true).create() s.edgeLabel('Pattern_p_witness_edge').asBase().properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']) .multiTimes().sortKeys('_gsp_eid').enableLabelIndex(true).create() s.edgeLabel('BACKGROUND_EDGE').asBase().properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']) .multiTimes().sortKeys('_gsp_eid').enableLabelIndex(true).create() s.edgeLabel('BACKGROUND_EDGE__0').withBase('BACKGROUND_EDGE').link('Random_label_1', 'Random_label_1') .properties(*['keep', 'property_float', '_gsp_eid']).nullableKeys(*['keep', 'property_float']).multiTimes().sortKeys('_gsp_eid') .enableLabelIndex(true).create() s.indexLabel('gsp_index_0').onV('Pattern_p_low').by('uid').secondary().create() s.indexLabel('gsp_index_1').onV('Pattern_p_high').by('uid').secondary().create() // Create the 50 start vertices in uid order. def vertexIds = [] def startProperties = [ [keep: true, value: 4L, property_float: 2.5d], [keep: true, value: 2L, property_float: 0.5d], [keep: true, value: 2L, property_float: 1.5d], [keep: true, value: 1L, property_float: 2.5d], [keep: true, value: 4L], [keep: true, value: 1L, property_float: 1.5d], [keep: false, value: 4L, property_float: 1.5d], [keep: false, value: 0L], [keep: true, value: 3L, property_float: 0.5d], [keep: true, value: 2L], [keep: true, value: 0L, property_float: 2.5d], [keep: true, value: 1L], [keep: true, value: 0L, property_float: 2.5d], [keep: true, value: 0L, property_float: 0.5d], [keep: true, value: 2L, property_float: 0.5d], [keep: true, value: 1L, property_float: 1.5d], [keep: true, value: 0L, property_float: 0.5d], [keep: true, value: 0L, property_float: 0.5d], [keep: true, value: 3L, property_float: 2.5d], [keep: true, value: 1L, property_float: 2.5d], [keep: true, value: 3L, property_float: 0.5d], [keep: true, value: 0L, property_float: 2.5d], [keep: true, value: 2L, property_float: 2.5d], [keep: true, value: 4L, property_float: 1.5d], [keep: true, value: 1L, property_float: 2.5d], [keep: true, value: 2L], [keep: true, value: 5L, property_float: 0.5d], [keep: true, value: 4L, property_float: 0.5d], [keep: true, value: 0L, property_float: 2.5d], [keep: false, value: 2L, property_float: 1.5d], [keep: false, value: 4L, property_float: 2.5d], [keep: true, value: 0L], [keep: false, value: 2L, property_float: 1.5d], [keep: true, value: 3L, property_float: 1.5d], [keep: false, value: 2L], [keep: false, value: 4L, property_float: 0.5d], [keep: true, value: 2L], [keep: true, value: 3L, property_float: 2.5d], [keep: true, value: 1L], [keep: true, value: 4L, property_float: 2.5d], [keep: true, value: 0L], [keep: true, value: 3L, property_float: 0.5d], [keep: true, value: 0L, property_float: 2.5d], [keep: true, value: 1L], [keep: false, value: 3L, property_float: 1.5d], [keep: true, value: 1L, property_float: 2.5d], [keep: true, value: 4L], [keep: true, value: 2L], [keep: true, value: 1L, property_float: 0.5d], [keep: true, value: 0L, property_float: 1.5d] ] startProperties.eachWithIndex { properties, uid -> def vertex = g.addV('Random_label_1').property('uid', uid as long).next() properties.each { k, v -> vertex.property(k, v) } vertexIds.add(vertex.id()) } graph.tx().commit() // Create one low neighbor and 2,000 high neighbors per start vertex. (0..<50).each { start -> long lowUid = 50L + 2001L * start vertexIds.add(g.addV('Pattern_p_low').property('uid', lowUid).property('keep', true).id().next()) (1L..2000L).each { offset -> vertexIds.add(g.addV('Pattern_p_high').property('uid', lowUid + offset) .property('keep', true).id().next()) if (offset % 250 == 0) graph.tx().commit() } } def backgroundEdges = [ [23, 32, true], [10, 28, true], [10, 32, false], [16, 23, true], [11, 45, true], [42, 16, true], [20, 44, true], [11, 47, true], [23, 4, false], [34, 26, false], [49, 46, true], [26, 16, true], [39, 35, true], [20, 25, false], [44, 22, true], [0, 28, true], [23, 39, false], [24, 13, true], [35, 10, false], [7, 2, false], [20, 25, true], [10, 4, false], [12, 16, false], [31, 40, true], [42, 22, true], [5, 35, false], [9, 12, true], [4, 49, false], [23, 47, false], [29, 33, true], [13, 9, true], [1, 31, true], [14, 7, false], [26, 10, true], [15, 39, true], [7, 49, true], [8, 7, false], [47, 43, true], [17, 39, true], [43, 25, true], [13, 8, true], [8, 4, false], [37, 31, true], [26, 5, false], [1, 43, false], [26, 33, false], [48, 15, true], [2, 20, true], [48, 34, true], [35, 32, true], [8, 17, true], [44, 2, true], [1, 1, false], [33, 24, true], [26, 32, true], [31, 38, true], [15, 38, true], [18, 3, true], [17, 23, false], [21, 49, true], [4, 17, false], [18, 26, false], [47, 6, true], [15, 49, true], [27, 41, false], [29, 41, true], [49, 28, false], [30, 7, true], [17, 9, true], [28, 38, true], [15, 48, true], [7, 46, false], [45, 36, true], [1, 46, false], [46, 48, true], [17, 24, false], [25, 22, true], [24, 11, true], [3, 33, true], [5, 1, false], [26, 38, true], [8, 32, true], [7, 34, true], [25, 21, false], [47, 2, false], [12, 34, true], [46, 44, true], [10, 18, true], [28, 21, true], [22, 24, true], [39, 25, true], [14, 3, true], [4, 40, true], [37, 42, false], [22, 33, true], [5, 38, true], [34, 28, true], [10, 32, true], [33, 38, true], [48, 1, true] ] backgroundEdges.eachWithIndex { edge, ordinal -> g.V(vertexIds[edge[0]]).addE('BACKGROUND_EDGE__0').to(__.V(vertexIds[edge[1]])) .property('keep', edge[2]).property('_gsp_eid', ordinal as long).iterate() } graph.tx().commit() (0..<50).each { start -> int lowUid = 50 + 2001 * start g.V(vertexIds[start]).addE('Pattern_p_low_edge__0') .to(__.V(vertexIds[lowUid])).property('_gsp_eid', 100L + 2001L * start).iterate() (1..2000).each { offset -> g.V(vertexIds[start]).addE('Pattern_p_high_edge__0') .to(__.V(vertexIds[lowUid + offset])) .property('_gsp_eid', 100L + 2001L * start + offset).iterate() if (offset % 250 == 0) graph.tx().commit() } } Run each query separately with `p0` bound to `true` (boolean). // q1 g.V().hasLabel("Random_label_1") .filter(__.not(__.out("Pattern_p_low_edge").has("keep",p0))) .identity() // q2 g.V().hasLabel("Random_label_1") .filter(__.not(__.out("Pattern_p_high_edge").has("keep",p0))) .identity() q1 `result.data` {"@type": "g:List", "@value": []} q2 `result.data` {"@type": "g:List", "@value": []} ``` ### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构) ```javascript //The combined schema endpoint returns HTTP 400 for the unused base edge label `Pattern_p_witness_edge`, which has zero endpoint pairs. The JSON below combines the REST responses for property keys, vertex labels and index labels with the edge label maps returned by the native schema API. Edge label maps use schema IDs for linked labels and property keys. { "propertykeys": [ { "id": 7, "name": "property_float", "data_type": "DOUBLE", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.047" } }, { "id": 6, "name": "p_anchor", "data_type": "LONG", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.046" } }, { "id": 8, "name": "_gsp_eid", "data_type": "LONG", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.047" } }, { "id": 3, "name": "value", "data_type": "LONG", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.046" } }, { "id": 2, "name": "keep", "data_type": "BOOLEAN", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.045" } }, { "id": 5, "name": "p_gate_false", "data_type": "BOOLEAN", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.046" } }, { "id": 4, "name": "p_gate_true", "data_type": "BOOLEAN", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.046" } }, { "id": 1, "name": "uid", "data_type": "LONG", "cardinality": "SINGLE", "aggregate_type": "NONE", "write_type": "OLTP", "properties": [], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.041" } } ], "vertexlabels": [ { "id": 1, "name": "Pattern_p_high", "id_strategy": "AUTOMATIC", "primary_keys": [], "nullable_keys": [ "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "index_labels": [ "gsp_index_1" ], "properties": [ "uid", "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "status": "CREATED", "ttl": 0, "enable_label_index": true, "user_data": { "~create_time": "2026-11-14 20:56:52.050" } }, { "id": 2, "name": "Pattern_p_low", "id_strategy": "AUTOMATIC", "primary_keys": [], "nullable_keys": [ "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "index_labels": [ "gsp_index_0" ], "properties": [ "uid", "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "status": "CREATED", "ttl": 0, "enable_label_index": true, "user_data": { "~create_time": "2026-11-14 20:56:52.050" } }, { "id": 3, "name": "Pattern_p_witness", "id_strategy": "AUTOMATIC", "primary_keys": [], "nullable_keys": [ "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "index_labels": [], "properties": [ "uid", "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "status": "CREATED", "ttl": 0, "enable_label_index": true, "user_data": { "~create_time": "2026-11-14 20:56:52.051" } }, { "id": 4, "name": "Random_label_1", "id_strategy": "AUTOMATIC", "primary_keys": [], "nullable_keys": [ "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "index_labels": [], "properties": [ "uid", "keep", "value", "p_gate_true", "p_gate_false", "p_anchor", "property_float" ], "status": "CREATED", "ttl": 0, "enable_label_index": true, "user_data": { "~create_time": "2026-11-14 20:56:52.051" } } ], "indexlabels": [ { "id": 1, "name": "gsp_index_0", "base_type": "VERTEX_LABEL", "base_value": "Pattern_p_low", "index_type": "SECONDARY", "fields": [ "uid" ], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.062" } }, { "id": 2, "name": "gsp_index_1", "base_type": "VERTEX_LABEL", "base_value": "Pattern_p_high", "index_type": "SECONDARY", "fields": [ "uid" ], "status": "CREATED", "user_data": { "~create_time": "2026-11-14 20:56:52.275" } } ], "edgelabels": [ { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "1", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.053" }, "name": "Pattern_p_high_edge", "links": [ { "4": 1 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 1, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "1", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.054" }, "name": "Pattern_p_high_edge__0", "links": [ { "4": 1 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 2, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "2", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.054" }, "name": "Pattern_p_low_edge", "links": [ { "4": 2 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 3, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "2", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.055" }, "name": "Pattern_p_low_edge__0", "links": [ { "4": 2 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 4, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.055" }, "name": "Pattern_p_witness_edge", "links": [], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 5, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "4", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.056" }, "name": "BACKGROUND_EDGE", "links": [ { "4": 4 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 6, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" }, { "ttlStartTime": "0", "sourceLabel": "4", "targetLabel": "4", "ttl": "0", "frequency": "MULTIPLE", "userdata": { "~create_time": "2026-11-14 20:56:52.056" }, "name": "BACKGROUND_EDGE__0", "links": [ { "4": 4 } ], "sortKeys": [ 8 ], "enableLabelIndex": true, "id": 7, "nullableKeys": [ 2, 7 ], "edgeLabelType": "NORMAL", "properties": [ 2, 7, 8 ], "indexLabels": [], "status": "created" } ] } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
