1 Vote Vote

Constant MySQL Connection or Connect when needed.

Posted by topdog 635 days ago Questions| connection mysql connection connect All

I am building a little daemon which periodically (every 30 seconds) checks for new data and enters it in a local MySQL Database.

I was just wondering whether it was better to create a connection to the database when the application launches and always use that connection throughout the application until it is closed, or if it should only open a connection when there is new data, close it after the data has been added and then repeat this when there is new data 30 seconds later?

Thank you.

Originally asked by: Jamza on Stack Overflow

Discuss Bury


Who Voted for this Question