Answer the question
In order to leave comments, you need to log in
What is better to return from SQL query to Golang array or channel?
Hello, I'm exploring the possibilities of working with Golang. In particular, there is a question about what is more productive in the task of obtaining data from the database and sending them via the SMTP server, since there can be several hundred thousand records
1) SQL -> structure channel -> go SMTP sending routine (one letter - one goroutine )
2) SQL -> array of structures -> batch formation -> go routine sending via SMTP (a batch of letters is one gorutin)
I would be very grateful for detailed advice.
Answer the question
In order to leave comments, you need to log in
I don’t understand the advantages of the second method - only the difficulties in forming packs.
Here is a simple example describing this type of task https://gobyexample.ru/worker-pools.html
If there is really too much data to get in one request, you will have to use a cursor.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question