PDA

View Full Version : QSQLDatabase



hoshy
3rd September 2009, 13:53
hi,

if I create a QSqlDatabase, the .open() method call is extremly slow.
Does anyone know whats wrong?

best

ps.: I'm connecting on a local database

wysota
3rd September 2009, 15:23
Please provide more details.

hoshy
4th September 2009, 12:07
I'm adding a database using the driver QPSQL7 :



m_db = QSqlDatabase();
...
m_db = QSqlDatabase::addDatabase(strType.c_str(), DB_NAME);
m_db.setHostName(strHostName.c_str());
m_db.setDatabaseName(strDatabaseName.c_str());
m_db.setUserName(strUserName.c_str());
m_db.setPassword(strPassword.c_str());
m_db.setPort(iPort);
...


while calling:


m_db.open();

my app blocks for about two seconds

wysota
4th September 2009, 18:07
Does it also block for two seconds if you use psql console? Maybe your database is clogged and needs some vacuuming? How did you calculate those two seconds, by the way? Like that?

QTime t;
t.start();
m_db.open();
qDebug() << t.elapsed();

hoshy
25th September 2009, 13:02
Yes I did that...

I tried to vacuum the database (VACUUM tablename; ) before calling

m_db.open()

But that caused a timedelay of 2,2 seconds... I have no clue whats wrong...

best,
Hoshy

wysota
25th September 2009, 15:09
Again, how do you calculate the delay?