From 1a54cda705f5afa62ebede76a4ad123e4be22f2f Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 14 Oct 2014 17:46:52 +0200 Subject: [PATCH] ClearPrivateData: Delete old favicons in Optimize DB option This should help anyone having issues with slow loading of bookmarks or searching in locationbar. --- src/lib/other/clearprivatedata.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index b6a7924d1..115b3c468 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -174,7 +174,16 @@ void ClearPrivateData::optimizeDb() const QString profilePath = DataPaths::currentProfilePath(); QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size()); - mApp->history()->optimizeHistory(); + // Delete icons for entries older than 6 months + const QDateTime date = QDateTime::currentDateTime().addMonths(-6); + + QSqlQuery query; + query.prepare(QSL("DELETE FROM icons WHERE id IN (SELECT id FROM history WHERE date < ?)")); + query.addBindValue(date.toMSecsSinceEpoch()); + query.exec(); + + query.clear(); + query.exec(QSL("VACUUM")); QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size());