title: Constant re-connection to database causes program to be slow
body: <p>So I've heard that it's good programming when you close your database connection as soon as you don't need that connection and just re-open it when you do. So, I've been closing my connection whenever I don't need it, however I've noticed that it's slowed down my program significantly (it takes ~2 seconds per window to open). Any way to solve this?</p>
  
  <p>I've defined <code>QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");</code> as a global, and just did <code>db.open();</code> or <code>db.close();</code> whenever I needed. In addition, if I just keep my connection open the whole time, my windows load instantly.</p>
  
  <p>Edit: Reason why people say this is because connections could get dropped/disconnected midway through using your program and it could lead to unsaved data/big problems etc</p>