Unsolved QSqlquery exec() slow in windows compared to linux
-
My application behaves extremely slow in windows compared to Linux. I analysed and figured out the reason. The cause is inserting data into the database through QSqlQuery exec() function creating slowness.My application Constantly writes data into database.
Analysis Result:
Time calculated before and after exec() with the help of Qtime object below as shown in code.
Below are the timing observed for the first 30 seconds of data.Linux(Debug mode) : Min time is 3 millisec ,Max time is 37 millisec
Linux(Release mode): Min time is 3 millisec ,Max time is 51 millisec
Windows(Debug mode): Min time is 124 millisec ,Max time is 224 millisec
Windows(release mode): Min time is 116 millisec ,Max time is 216 millisecFirst I prepared query through dbQuery_obj.prepare() statement and set setforwardonly() to be true to improve performance for accessing the database and added binding values through "addbindvalue()" one by one upto 13 elements and finally "exec()" is called to execute the query. The actual code looks like as below
dbQuery_obj.prepare("INSERT INTO ?('Time', Timestamp,xxxx,xxxx,......13 elements)"
" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
ret = dbQuery.prepare(sqlStatement);
dbQuery.setForwardOnly(true);
dbQuery.addBindValue((QString)TimeString);
dbQuery.addBindValue((int)Timestamp);
...
...
...QTime begin = QTime::currentTime();
ret = dbQuery.exec();
QTime end = QTime::currentTime();
qDebug() << "finished in " + QVariant(end.msec() - begin.msec()).toString() + " milli seconds";Whether it is known issue ? or Is there any way to improve the writing speed of data into database in windows ?
-
@Ravi-Sankar
Nobody will be able to comment if you do not even tell us what database you are using...?!Which one are you using? (Are you even using the same one on both Linux & Windows?) Which driver are you using? Is the database local to your Qt application or remote on a network? If it's on a network, are you using the actual same database server against your Linux/Windows clients, or different servers? Same versions of server database or different ones? Etc.!
-
oh...I forgot.
Database : SQLite Version 3. Same on both windows and Linux.
Driver : QSQLite
No change in code(same code in both platforms).
Database is local to Qt application -
@Ravi-Sankar What about the computers you use for Windows and Linux: are those similar (CPU, RAM, hard disk)?
-
@jsulm
Well Configured PCHost: Windows
Intel Xeon CPU E5-1650 V2
32GB Ram
4TB harddiskLinux in Oracle Virtual Box
10 GB RAM (out of 32 GB)
440 GB -
Hi, just guessing, but if you create a new Windows installation as a Oracle VirtualBox guest (so it will be a neighbor/brother to your Linux installation) and then test SQLite on that, I'm betting that it will perform with the same speed as in Linux, thanks to the heavy RAM buffering that Oracle Virtual Box does.
-
@Ravi-Sankar
Whatever the issue is, I doubt it will have anything to do with Qt per se. Though it may be inconvenient for you to test from outside.Are you sure all your SQLite (server) settings are identical in each of the two environments?
-
@JNBarchan
yes. Both the platform have same QSQlite driver.
And Same version of Qt5.5 is running in both platform. -
@Ravi-Sankar
OK. Then I would look at the performance of SQLite itself on the two OSes, rather than Qt itself. @hskoglund's post above might be worth investigating?