Skip to content

Commit

Permalink
fix: cachedimage add index (#17843)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
  • Loading branch information
swordqiu and Qiu Jian authored Aug 23, 2023
1 parent ea6f169 commit 43f25db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/compute/models/cachedimages.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func init() {
),
}
CachedimageManager.SetVirtualObject(CachedimageManager)
CachedimageManager.TableSpec().AddIndex(false, "deleted", "domain_id", "tenant_id", "image_type")
}

type SCachedimage struct {
Expand Down Expand Up @@ -884,7 +885,8 @@ func (manager *SCachedimageManager) ListItemFilter(
}

if idFilter {
q = q.In("id", subq)
subQ := subq.Distinct().SubQuery()
q = q.Join(subQ, sqlchemy.Equals(q.Field("id"), subQ.Field("cachedimage_id")))
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/compute/models/storages.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func init() {
),
}
StorageManager.SetVirtualObject(StorageManager)
StorageManager.TableSpec().AddIndex(false, "deleted", "status", "enabled", "zone_id", "storagecache_id")
}

type SStorage struct {
Expand Down

0 comments on commit 43f25db

Please sign in to comment.