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: 170

Filed under:
|
|

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)?

  1. Kill the last connection
  2. Wait for API call to complete
  3. Create new DB connection
  4. Execute query
  5. Goto 1

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database