Refine the sql to query non empty repositories (#22269)

use exists instead of in condition

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2025-08-21 18:07:41 +08:00 committed by GitHub
parent 747d54d70e
commit 63b61d6995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -159,7 +159,7 @@ func (d *dao) NonEmptyRepos(ctx context.Context) ([]*model.RepoRecord, error) {
return nil, err
}
sql := `select * from repository where repository_id in (select distinct repository_id from tag)`
sql := `select * from repository where exists (select 1 from tag where tag.repository_id = repository.repository_id)`
_, err = ormer.Raw(sql).QueryRows(&repos)
if err != nil {
return repos, err