E
E
Egor Mikheev2019-06-18 20:26:37
go
Egor Mikheev, 2019-06-18 20:26:37

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

1 answer(s)
D
Dmitry Shitskov, 2019-06-18
@ogregor

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 question

Ask a Question

731 491 924 answers to any question