Improve metricDB query performance

Remarkably, using transactions even when querying
SQLITE databases improves performance. If you have
a lot of metric charts on the home window then this
patch will make startup a lot faster.

Additionally, as we refresh the charts as rides are
added and deleted this should help to reduce the
performance impact when lots of charts are open.

There is an SQLITE performance FAQ that provides
more background here;

http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html
This commit is contained in:
Mark Liversedge
2011-08-07 11:13:25 +01:00
parent fd816f7e1e
commit 72338d56e1

View File

@@ -293,7 +293,13 @@ MetricAggregator::getAllMetricsFor(QDateTime start, QDateTime end)
qDebug()<<"lost db connection?";
return empty;
}
return dbaccess->getAllMetricsFor(start, end);
// apparently using transactions for queries
// can improve performance!
dbaccess->connection().transaction();
QList<SummaryMetrics> results = dbaccess->getAllMetricsFor(start, end);
dbaccess->connection().commit();
return results;
}
QList<SummaryMetrics>