Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fr11nik opened this issue Jun 23, 2024 · 1 comment

Comments

@fr11nik
Copy link

fr11nik commented Jun 23, 2024

res, err := a.authorRepo.GetByID(ctx, authorID)

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
Copy link
Author

fr11nik commented Jun 23, 2024

There's difference in perfomance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant