I query the remote MSSQL Server database using QODBC and I have a returned result set, but it looks like it sends a SQL Server query for each record one at a time. It is very slow to repeat a set of results. Executing a request from Qt, it takes about 15 seconds. I performed the same query in SQL Server Management Studio, and it takes 1 second to return the results. Here is the code I'm using:
QString connectionTemplate = "DRIVER={SQL SERVER};SERVER=server;DATABASE=db;"; QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3", "db"); db.setDatabaseName(connectionTemplate); db.setUserName("user"); db.setPassword("password"); if (db.open()) { qDebug() << "OK!"; QSqlQuery * query = new QSqlQuery(db); query->exec("SELECT [UserName]" " FROM [dbo].[Users]"); while(query->next()) { QString userName = query->value(0).toString(); qDebug() << userName; } db.close(); } else { qDebug() << db.lastError().text(); }
Is there a way to capture the entire result set into memory and skip it in memory? I would prefer that the application does not take so much time to iterate through the result set.
source share