perf: avoid correlated channel scans in portrait queries

This commit is contained in:
Yvan
2026-11-05 17:11:59 +08:00
parent a43d140339
commit aaee077253
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ func (r *channelRepo) Games(ctx context.Context, scope business.ChannelGameScope
mode = 1
}
query := func(table string, dedup int) *gorm.DB {
return db.Table(table+" r").Where("r.source_db = ? AND r.game_id > 0 AND r.dedup_mode = ?", scope.Root.SourceDB, dedup).Where("EXISTS (?)", channelGameTree(db, scope).Select("1").Where("p.id=r.promote_id AND p.source_db=r.source_db"))
return db.Table(table+" r").Where("r.source_db = ? AND r.game_id > 0 AND r.dedup_mode = ?", scope.Root.SourceDB, dedup).Where("(r.source_db,r.promote_id) IN (?)", channelGameTree(db, scope).Select("p.source_db,p.id"))
}
// 累计起点按当前人数口径的日汇总最早日期决定,与原画像查询一致。
begin := scope.BeginDate