请问match语句如何调优呢,集群资源使用率不高的情况下,性能不够理想?

业务上使用match语句,统计某个节点作为起点、经过指定类型边、在4步内 属性符合指定要求的节点数量,比较典型的查询如下:

return 返回多个结果是为了业务上减少总查询次数,把前面条件相同的查询做了查询合并;

遇到的问题:
1、在集群资源总体使用了不高的情况下,耗时抖动比较大,比如监测到某条耗时超过100ms,拿下来到控制台再次查询,耗时往往不到10ms,观察发生的时间点的流量及集群资源使用情况,都挺正常的
2、对于简单的图结构,以上语句耗时总体能比较快,但是对于略微复杂的图结构耗时往往超过要求上限(30ms以内),结合一下第三点,改如何进行调优呢?
3、如何提供集群资源使用率,以提高查询性能?此前优化了graph节点的num_worker_threads参数,8核的机器,参数从8提高至32,发现并无效果;翻了一遍官网文档,和性能相关的参数还有以下这些:


4、profile语句返回的结果解析哪里有详细说明文档吗?官网文档只有简单实用说明,并无详细解析;
5、尝试过改写为find path,get subgraph,无法做到等效的查询,是否有其他建议呢?
6、对于我这个case,match语句指定了起点,边和终点的属性过滤是在内存中二次筛选吧,此时再加索引应该是无效的?

感谢!

go 0 to 3 steps from "player100" over serve,follow bidirect yield distinct id($$) as did,properties($$).age  as age,properties($$).name as name | yield count(case $-.age >0 when true then $-.age end) as age, count(case $-.name contains ("T") when true then $-.name end) as name

如果你只是要点的话,可以考虑用 go,供参考

昨天实测是发现报错,go语句的yield里不能用count等聚合函数

go 0 to 3 steps from "100" over serve,follow bidirect 
yield $$ as did,properties($$).age as age,properties($$).name as name | 
group by $-.did yield $-.did as did | 
yield
 count(case properties($-.did).age >0 when true then properties($-.did).age end) as age,
 count(case properties($-.did).name contains ("T") when true then properties($-.did).name end) as name

加个 groupby 试试

可逻辑上并不需要group by呢,group by哪个字段呢,我要统计属性满足某些条件的个数;

groupby 和 distinct 的在这个语句里面是一样的作用,用于对 v1 进行去重

go 0 to 3 steps from "100" over serve,follow bidirect 
yield distinct id($$) as did,properties($$).age as age,properties($$).name as name |
yield
 count(case $-.age >0 when true then $-.age end) as age,
 count(case $-.name contains ("T") when true then $-.name end) as name

感谢回复,yield返回终点as v1,到这一步没错,可加上后面的yield count就有语法错误呢?

语法问题,管道符后面的语句如果想使用上一条语句返回值的变量需要加 $- 就像我之前发的那样

properties($-.v1).abnormal_107_cancel_list 这样就行了

1 个赞

还是有错误呢,是我哪里用法不对吗

不会啊,我上面跑成功了啊?

建议你仔细看下我上面发的语句哈。

你这个提示错误是因为 v1 是 id,不是 vertex,id 是没有属性的

感谢感谢,最终改写成功了,但实测下来就相同语句耗时还不如match,耗时几乎是2倍:
go 0 to 3 steps from “100” over e_user_id,e_device_id,e_finger_id,e_open_id,e_buyer_account bidirect
where (properties(edge).strong_associations==1 OR properties(edge).all_latest_time>=20241214000000)
yield distinct $$ as v1 |
yield COUNT(CASE properties($-.v1).abnormal_107_cancel_list>=1736780487 WHEN true THEN $-.v1 END) as cnt;

另外我提的提个几个问题能否支持下,我们急切地需要解决查询性能方面的问题,感谢!

你是啥版本?

v3.6.0,还是挺新的版本了