From bf122ad7160174bc232fa05f9113e8452d8811b2 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Tue, 25 Oct 2011 08:48:03 +0200 Subject: [PATCH] Db performance tweaks. --- larss/feedpoller.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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"; } -- 2.1.4