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