优化服务列表查询

This commit is contained in:
刘祥超
2023-03-27 17:14:12 +08:00
parent 9bf46af088
commit 873af38807

View File

@@ -784,9 +784,11 @@ func (this *ServerDAO) CountAllEnabledServersMatch(tx *dbs.Tx, groupId int64, ke
} }
if userId > 0 { if userId > 0 {
query.Attr("userId", userId) query.Attr("userId", userId)
query.UseIndex("userId")
} }
if clusterId > 0 { if clusterId > 0 {
query.Attr("clusterId", clusterId) query.Attr("clusterId", clusterId)
query.UseIndex("clusterId")
} }
if auditingFlag == configutils.BoolStateYes { if auditingFlag == configutils.BoolStateYes {
query.Attr("isAuditing", true) query.Attr("isAuditing", true)
@@ -840,9 +842,11 @@ func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size in
} }
if userId > 0 { if userId > 0 {
query.Attr("userId", userId) query.Attr("userId", userId)
query.UseIndex("userId")
} }
if clusterId > 0 { if clusterId > 0 {
query.Attr("clusterId", clusterId) query.Attr("clusterId", clusterId)
query.UseIndex("clusterId")
} }
if auditingFlag == 1 { if auditingFlag == 1 {
query.Attr("isAuditing", true) query.Attr("isAuditing", true)