查询性能优化

  • nebula 版本:3.4
  • 部署方式:分布式 (三台服务器,各部署meta,graph,stroage独立服务节点)
  • 安装方式:RPM
  • 硬盘:HDD
    CPU:16核
    内存:256G
  • 问题描述:
    不知道起始点和终止点,需查询出某条路径上所有点的id,使用match查询太慢,目前使用lookup第一个tag所有的点,然后管道查询关联下一个tag的点,依次查询到最后一个tag,然后把所有点id返回,但是性能较差,请教下怎么调优或者有没有其他更好的写法。
    附上查询语句和执行计划

查询路径1介绍 :

vnf->vm->server->switch->switch
数据大小
vnf:6K+
vm:30W+
server:10W+
switch:2W+
路径查询数据量:1051413 耗时:28s+

查询语句:

LOOKUP ON vnf yield id(vertex) as vnfid | 
GO FROM $-.vnfid OVER rel_virtual_machine_vnf  YIELD dst(edge) as virtual_machineid,$-.vnfid as vnfid | 
GO FROM $-.vnfid OVER rel_virtual_machine_vnf  YIELD dst(edge) as virtual_machineid,$-.vnfid as vnfid | 
GO FROM $-.compute_serverid OVER rel_hardware_hardware  YIELD dst(edge) as switchid,$-.compute_serverid as compute_serverid,$-.virtual_machineid as virtual_machineid,$-.vnfid as vnfid |  
GO FROM $-.switchid OVER rel_network_device  YIELD dst(edge) as switch1id,$-.switchid as switchid,$-.compute_serverid as compute_serverid,$-.virtual_machineid as virtual_machineid,$-.vnfid as vnfid

执行计划:




查询路径2介绍:

port->port->switch
数据量:
port:180W+
switch:2W+
路径查询数据大小:127703,耗时:34s+

查询语句:

LOOKUP ON netdevice_physical_port yield id(vertex) as netdevice_physical_portid |
GO FROM $-.netdevice_physical_portid OVER rel_netdevice_physical_port_netdevice_physical_port  YIELD dst(edge) as netdevice_physical_port1id,$-.netdevice_physical_portid as netdevice_physical_portid | 
GO FROM $-.netdevice_physical_port1id OVER rel_physical_port_network_device  YIELD dst(edge) as switchid,$-.netdevice_physical_port1id as netdevice_physical_port1id,$-.netdevice_physical_portid as netdevice_physical_portid

执行计划



都 profile 下看下具体耗时吧, 不过你这两个查询都不指定点id, 只能扫 tag 下的全量, 提升很有限

上面 Aiee 说的提升空间,你可以参考 Wey 写的这篇文章哈 nGQL 简明教程 vol.02 执行计划详解与调优

  • 起点是全扫描的,考虑分批几个客户端请求的查询同时发出去试试
  • HDD → SDD
  • 存储里把 query_concurrently 设置 true 试试,这个开并行是面向你这种 AP 量起点查询的。
  • 具体的语句调优确实空间不大,可以看看 rel_virtual_machine_vnf._dst 替代 dst(edge) 试试

居然见到了 NFV 的例子,推荐一下我的 OpenStack 文章哈 https://www.siwei.io/graph-enabled-infra-ops/

3 个赞

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。