bxcodec / go-clean-arch

Go (Golang) Clean Architecture based on Reading Uncle Bob's Clean Architecture
MIT License
9.03k stars 1.19k forks source link

question: combine all ids into one row and execute as one query it's better way? #106

Open fr11nik opened 2 months ago

fr11nik commented 2 months ago

https://github.com/bxcodec/go-clean-arch/blob/e06c6d0cb37069b0ef56e3df67f80ca130a1ab82/article/service.go#L63 in

for authorID := range mapAuthors {
        authorID := authorID
        g.Go(func() error {
            res, err := a.authorRepo.GetByID(ctx, authorID)
            if err != nil {
                return err
            }
            chanAuthor <- res
            return nil
        })
    }

better to do?

authors, err := a.authorRepo.GetByIDS(ctx, authorIDS)
if err != nil {
    return err
}
for _, author := range authors {
    chanAuthor <- res
}
fr11nik commented 2 months ago

There's difference in perfomance?