Hi. I'm exporting some data from a Firebird database to a text file.

The code is as follow:

Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QIBASE");
  2.  
  3. db.setHostName("127.0.0.1");
  4. db.setDatabaseName("DATABASE");
  5. db.setPort(3052);
  6. db.setUserName("USER");
  7. db.setPassword("PASS");
  8.  
  9. if (db.open()) {
  10. QSqlQuery query(db);
  11.  
  12. query.prepare(SQL);
  13. query.setForwardOnly(true);
  14.  
  15. if (query.exec()) {
  16. QFile file("C:/Users/NAME/Desktop/Sync.txt");
  17.  
  18. if (file.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
  19. while (query.next()) {
  20. QString rec;
  21.  
  22. for (int i = 0; i < query.record().count(); ++i) {
  23. rec = rec + query.value(i).toString().append("|");
  24. }
  25.  
  26. file.write(rec.append("\n").toStdString().c_str());
  27. }
  28.  
  29. file.close();
  30. } else {
  31. qDebug() << "Error: " << file.errorString();
  32. }
  33. } else {
  34. qDebug() << "Error: " << query.lastError().text();
  35. }
  36. } else {
  37. qDebug() << "Error: " << db.lastError().databaseText();
  38. }
To copy to clipboard, switch view to plain text mode 

The table referenced in the SQL has 10k records. And the exported file is around 1MB.

Using QIBase it takes 05:41 approximately.

The same table in a MySQL database with the same data takes around 01:13.

However, this same firebird database accessed through Delphi. Generate this file under 10 seconds.

Could this poor performance be related to the Qt SQL drivers?

Is there any way I could improve the overall performance of this type of code?

Thanks!