Skip to content

[Question] 有哪些方法可以调优查询 #2836

@vvvice

Description

@vvvice

Problem Type (问题类型)

performance (性能优化)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • Server Version: 1.5.0 (Apache Release Version)
  • Backend: cassandra 3 nodes, HDD
  • OS: 8 CPUs, 16G RAM, CentOS 7.x
  • Data Size: 100W vertices, 100W edges

Your Question (问题描述)

执行下列语句时并发压力测试,并发数量每次都把cpu占用压到百分之八九十发现qps不高,和官网给的性能数据相差上千倍,而且偶尔会出现超时,环境是通过nginx代理了三个server节点
1.g.V().has('sourceIPAddress','iP','192.168.1.13').outE('produce').inV().hasLabel('accessBehavior').outE('associatedOperation').inV().has('businessOperation','operateUUID','opu294').outE('result').inV().valueMap();
2.g.V().has('sourceIPAddress','iP','192.168.1.11').outE('produce').inV().hasLabel('accessBehavior').has('time',gt('2025-07-04 14:41:32.391')).has('time',lt('2025-07-04 15:00:22.158')).outE('associatedOperation').inV().hasLabel('businessOperation').values('operateUUID');
3.g.V().out();
4.g.V().out().out();
利用下列javaapiqps很低且偶尔oom
1.traverser.shortestPath(sourceId, targetId, 4);
2.traverser.kneighbor(sourceId, 2);
如何优化语句或者优化schema或者更改某些配置优化

Vertex/Edge example (问题点 / 边数据举例)

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

SchemaManager schema = hugeClient.schema();
        schema.propertyKey("iP").asText().ifNotExist().create();
        schema.propertyKey("behaviorTrackingID").asText().ifNotExist().create();
        schema.propertyKey("time").asDate().ifNotExist().create();
        schema.propertyKey("loginMethod").asText().ifNotExist().create();
        schema.propertyKey("ecologicalSubject").asText().ifNotExist().create();
        schema.propertyKey("userName").asText().ifNotExist().create();
        schema.propertyKey("operateUUID").asText().ifNotExist().create();
        schema.propertyKey("operationName").asText().ifNotExist().create();
        schema.propertyKey("operationRemarks").asText().ifNotExist().create();
        schema.propertyKey("voucherType").asText().ifNotExist().create();
        schema.propertyKey("voucherContent").asText().ifNotExist().create();
        schema.propertyKey("kid").asText().ifNotExist().create();
        schema.propertyKey("certificate").asText().ifNotExist().create();
        schema.propertyKey("publicKey").asText().ifNotExist().create();
        schema.propertyKey("businessObjectType").asText().ifNotExist().create();
        schema.propertyKey("identification").asText().ifNotExist().create();
        schema.propertyKey("name").asText().ifNotExist().create();
        schema.propertyKey("result").asText().ifNotExist().create();
        schema.propertyKey("reason").asText().ifNotExist().create();
        schema.propertyKey("verificationResult").asText().ifNotExist().create();
        schema.propertyKey("type").asText().ifNotExist().create();
        schema.propertyKey("codeAssignmentIdentification").ifNotExist().create();
        schema.propertyKey("clientID").asText().ifNotExist().create();
        schema.propertyKey("URL").asText().ifNotExist().create();
        schema.vertexLabel("sourceIPAddress")
                .usePrimaryKeyId()
                .properties("iP")
                .primaryKeys("iP")
                .ifNotExist()
                .create();
        schema.vertexLabel("accessBehavior")
                .properties("behaviorTrackingID", "time")
                .primaryKeys("behaviorTrackingID")
                .ifNotExist()
                .create();
        schema.vertexLabel("userIdentityCertificate")
                .properties("loginMethod", "ecologicalSubject", "userName")
                .ifNotExist()
                .create();
        schema.vertexLabel("businessOperation")
                .properties("operateUUID", "operationName", "operationRemarks")
                .primaryKeys("operateUUID")
                .ifNotExist()
                .create();
        schema.vertexLabel("oIDCIdentityCredential")
                .properties("voucherType", "voucherContent")
                .primaryKeys("voucherType")
                .ifNotExist()
                .create();
        schema.vertexLabel("keyPairsIdentityCredentials")
                .properties("kid", "certificate", "publicKey")
                .primaryKeys("kid")
                .ifNotExist()
                .create();
        schema.vertexLabel("businessObject")
                .properties("businessObjectType", "identification", "name")
                .primaryKeys("identification")
                .ifNotExist()
                .create();
        schema.vertexLabel("operationResult")
                .properties("operateUUID", "result", "reason")
                .primaryKeys("operateUUID")
                .ifNotExist()
                .create();
        schema.vertexLabel("technicalSystemIdentity")
                .properties("verificationResult", "type", "codeAssignmentIdentification", "clientID")
                .ifNotExist()
                .create();
        schema.vertexLabel("userIdentity")
                .properties("verificationResult", "userName")
                .ifNotExist()
                .create();
        schema.vertexLabel("page")
                .properties("URL")
                .primaryKeys("URL")
                .ifNotExist()
                .create();
        schema.vertexLabel("frontEndAndBackEndInterfaces")
                .properties("URL")
                .primaryKeys("URL")
                .ifNotExist()
                .create();
        schema.vertexLabel("capabilityOpenInterface")
                .properties("URL")
                .primaryKeys("URL")
                .ifNotExist()
                .create();
        schema.edgeLabel("produce")
                .sourceLabel("sourceIPAddress")
                .targetLabel("accessBehavior")
                .ifNotExist()
                .create();
        schema.edgeLabel("adoptVouchers_1")
                .sourceLabel("accessBehavior")
                .targetLabel("userIdentityCertificate")
                .ifNotExist()
                .create();
        schema.edgeLabel("associatedOperation")
                .sourceLabel("accessBehavior")
                .targetLabel("businessOperation")
                .ifNotExist()
                .create();
        schema.edgeLabel("adoptVouchers_2")
                .sourceLabel("accessBehavior")
                .targetLabel("oIDCIdentityCredential")
                .ifNotExist()
                .create();
        schema.edgeLabel("adoptVouchers_3")
                .sourceLabel("accessBehavior")
                .targetLabel("keyPairsIdentityCredentials")
                .ifNotExist()
                .create();
        schema.edgeLabel("operationObject")
                .sourceLabel("businessOperation")
                .targetLabel("businessObject")
                .ifNotExist()
                .create();
        schema.edgeLabel("result")
                .sourceLabel("businessOperation")
                .targetLabel("operationResult")
                .ifNotExist()
                .create();
        schema.edgeLabel("trueIdentity_1")
                .sourceLabel("accessBehavior")
                .targetLabel("technicalSystemIdentity")
                .ifNotExist()
                .create();
        schema.edgeLabel("trueIdentity_2")
                .sourceLabel("accessBehavior")
                .targetLabel("userIdentity")
                .ifNotExist()
                .create();
        schema.edgeLabel("visitCross_section_1")
                .sourceLabel("accessBehavior")
                .targetLabel("page")
                .ifNotExist()
                .create();
        schema.edgeLabel("visitCross_section_2")
                .sourceLabel("accessBehavior")
                .targetLabel("frontEndAndBackEndInterfaces")
                .ifNotExist()
                .create();
        schema.edgeLabel("visitCross_section_3")
                .sourceLabel("accessBehavior")
                .targetLabel("capabilityOpenInterface")
                .ifNotExist()
                .create();
        schema.edgeLabel("adoptKey")
                .sourceLabel("oIDCIdentityCredential")
                .targetLabel("keyPairsIdentityCredentials")
                .ifNotExist()
                .create();
        schema.indexLabel("accessBehaviorByTime")
                .onV("accessBehavior")
                .by("time")
                .range()
                .ifNotExist()
                .create();
        schema.indexLabel("userIdentityCertificateByUserName")
                .onV("userIdentityCertificate")
                .by("userName")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("businessOperationByOperationName")
                .onV("businessOperation")
                .by("operationName")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("businessOperationByOperationRemarks")
                .onV("businessOperation")
                .by("operationRemarks")
                .search()
                .ifNotExist()
                .create();
        schema.indexLabel("businessObjectByBusinessObjectType")
                .onV("businessObject")
                .by("businessObjectType")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("businessObjectByName")
                .onV("businessObject")
                .by("name")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("operationResultByResult")
                .onV("operationResult")
                .by("result")
                .search()
                .ifNotExist()
                .create();
        schema.indexLabel("operationResultByReason")
                .onV("operationResult")
                .by("reason")
                .search()
                .ifNotExist()
                .create();
        schema.indexLabel("technicalSystemIdentityByVerificationResult")
                .onV("technicalSystemIdentity")
                .by("verificationResult")
                .search()
                .ifNotExist()
                .create();
        schema.indexLabel("technicalSystemIdentityByType")
                .onV("technicalSystemIdentity")
                .by("type")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("technicalSystemIdentityByCodeAssignmentIdentification")
                .onV("technicalSystemIdentity")
                .by("codeAssignmentIdentification")
                .secondary()
                .ifNotExist()
                .create();
        schema.indexLabel("technicalSystemIdentityByClientID")
                .onV("technicalSystemIdentity")
                .by("clientID")
                .secondary()
                .ifNotExist()
                .create();
        //userIdentity--verificationResult--verificationResult--userName
        schema.indexLabel("userIdentityByVerificationResult")
                .onV("userIdentity")
                .by("verificationResult")
                .search()
                .ifNotExist()
                .create();
        schema.indexLabel("userIdentityByUserName")
                .onV("userIdentity")
                .by("userName")
                .secondary()
                .ifNotExist()
                .create();

Metadata

Metadata

Assignees

No one assigned

    Labels

    inactivequestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions