perf(接口测试): 引用关系图查询 SQL 优化
This commit is contained in:
parent
c0660e8827
commit
1bfa2afbcb
|
@ -3,15 +3,19 @@
|
|||
<mapper namespace="io.metersphere.base.mapper.ext.BaseRelationshipEdgeMapper">
|
||||
|
||||
<select id="getGraphIdsByNodeIds" resultType="java.lang.String">
|
||||
select distinct graph_id
|
||||
select graph_id
|
||||
from relationship_edge
|
||||
where source_id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
or target_id in
|
||||
union
|
||||
select graph_id
|
||||
from relationship_edge
|
||||
where target_id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -293,9 +293,11 @@ public class RelationshipEdgeService {
|
|||
if (CollectionUtils.isEmpty(graphIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
RelationshipEdgeExample example = new RelationshipEdgeExample();
|
||||
example.createCriteria()
|
||||
.andGraphIdIn(graphIds);
|
||||
.andGraphIdIn(graphIds.stream()
|
||||
.distinct().collect(Collectors.toList()));
|
||||
|
||||
return relationshipEdgeMapper.selectByExample(example);
|
||||
}
|
||||
|
@ -319,7 +321,7 @@ public class RelationshipEdgeService {
|
|||
markSet.add(id);
|
||||
visitedSet.add(id);
|
||||
|
||||
ArrayList<String> nextLevelNodes = new ArrayList();
|
||||
ArrayList<String> nextLevelNodes = new ArrayList<>();
|
||||
for (RelationshipEdge relationshipEdge : edges) {
|
||||
if (id.equals(relationshipEdge.getSourceId())) {
|
||||
nextLevelNodes.add(relationshipEdge.getTargetId());
|
||||
|
|
Loading…
Reference in New Issue