To create new DB connection or not?
Posted
by Yeti
on Stack Overflow
See other posts from Stack Overflow
or by Yeti
Published on 2010-06-16T06:16:13Z
Indexed on
2010/06/16
6:22 UTC
Read the original article
Hit count: 193
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
© Stack Overflow or respective owner