Db performance tweaks.
Leonardo Robol [2011-10-25 06:48]
diff --git a/larss/feedpoller.cpp b/larss/feedpoller.cpp
index 92f808f..011f576 100644
--- a/larss/feedpoller.cpp
+++ b/larss/feedpoller.cpp
@@ -88,6 +88,9 @@ FeedPoller::networkManagerReplyFinished(QNetworkReply *reply)
QDomDocument doc;
if (doc.setContent(rssContent->value(nowLoading)))
{
+ // Get transaction to support, otherwise the db will die
+ parser->db.transaction();
+
// Try to catch other news_feed with the same link, so preload all of them.
QSqlQuery query(parser->db);
query.prepare ("SELECT link from news WHERE feed=:feed");
@@ -151,9 +154,15 @@ FeedPoller::networkManagerReplyFinished(QNetworkReply *reply)
if (!parser->insertRecord(-1, record))
qDebug () << "Error inserting record";
+
+ // Yield to try making the UI responsive.
+ yieldCurrentThread();
}
}
+ // Commit the changes.
+ parser->db.commit();
+
if (!parser->submitAll())
qDebug() << "Error submitting new data";
}