fix: 修复大规模数据性能与流式状态清理

This commit is contained in:
chuan
2026-08-15 18:09:54 +08:00
parent 072ed8f168
commit ddebe3c4a2
15 changed files with 439 additions and 97 deletions
+2 -2
View File
@@ -143,7 +143,7 @@ func (r *SQLiteUsageRepository) QueryUsage(ctx context.Context, input collection
}
where, args := usageWhere(query)
var total int64
if err := r.db.QueryRowContext(ctx, `SELECT COUNT(*) FROM request_detail_index d WHERE `+where, args...).Scan(&total); err != nil {
if err := r.readDB.QueryRowContext(ctx, `SELECT COUNT(*) FROM request_detail_index d WHERE `+where, args...).Scan(&total); err != nil {
return collection.UsagePage{}, fmt.Errorf("统计请求明细: %w", err)
}
totalPages := 0
@@ -179,7 +179,7 @@ func (r *SQLiteUsageRepository) QueryUsage(ctx context.Context, input collection
} else {
statement += " LIMIT ? OFFSET ?"
}
rows, err := r.db.QueryContext(ctx, statement, limitArgs...)
rows, err := r.readDB.QueryContext(ctx, statement, limitArgs...)
if err != nil {
return collection.UsagePage{}, fmt.Errorf("查询请求明细: %w", err)
}