I am writing a server backend for an android app which needs to access a database. My backend application and the SQL server are on the same machine so I don't have to worry about traffic slowing down my application but I don't know how to get user data from the database in the most efficient way.
When a new user connects to the server, a new thread is started for managing that connection. The client sends a few packets for identification but eventually all clients need some online data every t seconds. This t is the same for every client. The clients don't need to request this data every t seconds, instead the server sends it to them. The data itself is on a SQL server and is updated every few seconds.
Now I want to know which one is better (for CPU performance - both my application and the SQL server itself):
Create a new connection to the SQL server for each thread and let the thread handle it.
Create only one connection to the SQL server and instead have a list of clients that need online data. Get all the needed data form the SQL server every
tseconds and then distribute that data between threads so that they can send it to the client.
There will be at most 300 clients.
EDIT: To clarify, I'm writing my application using C++ and using SQLAPI++ for database connections and I'm not sure if this library actually uses connection pooling.
Still, even if I leave the connection management to the library, the question is: Should I let each thread execute its own commands or have one thread execute them all at once in the form of one command? Does it have a significant impact on performance? (my application or the SQL server)