Reputation: 549
I was wondering if it is good practice for an application that is not used by many user to open a db connetion when the application starts up and close it again when it closes down.
Upvotes: 1
Views: 21
Reputation: 387
Depends on the maximum number of simultaneous connections available to the database. If it is on the low side, i'd rather not waste a connection being always online as that reduce the number of free connections available to the db as such. And its also possible to se tthe max and min number of connections to the db. Also if the software makes continuous calls to the db to do any CRUD operation, then it is better to have a open connection for a long time as the overhead for opening a new connection is a little bit high. Or depending on your application, you can have a workflow that puts all the db accesses in the same temporal locality so that, you only need to use the connection during that time. I hope this helps
Upvotes: 1