To create new DB connection or not?
- by Yeti
I'm running a cron job (every 15 minutes) which takes about a minute to execute. It makes lots of API calls and stores data to the database.
Right now I create a mysql connection at the beginning and use the same connection through out the code. Most of the time is spent making the API calls.
Will it be more efficient to create a new database connection only when it's time to store the data (below)?
Kill the last connection
Wait for API call to complete
Create new DB connection
Execute query
Goto 1