优化指标数据清理

This commit is contained in:
刘祥超
2021-12-03 12:16:00 +08:00
parent c406536511
commit fa31e547a2
2 changed files with 2 additions and 0 deletions

View File

@@ -481,6 +481,7 @@ func (this *MetricStatDAO) Clean(tx *dbs.Tx) error {
_, err := this.Query(tx).
Attr("itemId", item.Id).
Lte("createdDay", expiresDay).
UseIndex("createdDay").
Limit(100_000). // 一次性不要删除太多,防止阻塞其他操作
Delete()
if err != nil {

View File

@@ -188,6 +188,7 @@ func (this *MetricSumStatDAO) Clean(tx *dbs.Tx) error {
Attr("itemId", item.Id).
Where("(createdDay IS NULL OR createdDay<:day)").
Param("day", expiresDay).
UseIndex("createdDay").
Limit(100_000). // 一次性不要删除太多,防止阻塞其他操作
Delete()
if err != nil {