|
Rex Dieter |
adf30af |
From 7cbff48f5782d1f7f844678e6b785aeb419b0c47 Mon Sep 17 00:00:00 2001
|
|
Rex Dieter |
adf30af |
From: Milian Wolff <mail@milianw.de>
|
|
Rex Dieter |
adf30af |
Date: Mon, 1 Dec 2014 11:59:12 +0100
|
|
Rex Dieter |
adf30af |
Subject: [PATCH 18/30] Optimize: Skip value condition on invalid flags.
|
|
Rex Dieter |
adf30af |
|
|
Rex Dieter |
adf30af |
HandlerHelper::itemWithFlagsCount gets called quite often apparently
|
|
Rex Dieter |
adf30af |
and I noticed that it was relatively slow from the Query Debugger
|
|
Rex Dieter |
adf30af |
in Akonadi Console. EXPLAIN'ing the query showed that it was using
|
|
Rex Dieter |
adf30af |
a slow-path for the WHERE FOO AND (BAR OR ASDF) condition. Here,
|
|
Rex Dieter |
adf30af |
ASDF was always id = -1, the id of the $IGNORED flag, which
|
|
Rex Dieter |
adf30af |
I apparently don't have. Getting rid of that condition simplifies
|
|
Rex Dieter |
adf30af |
the query to WHERE FOO AND BAR, which is apparently much better
|
|
Rex Dieter |
adf30af |
optimizable. Before, the query often showed a runtime of ~15ms.
|
|
Rex Dieter |
adf30af |
Now it is down to ~9ms.
|
|
Rex Dieter |
adf30af |
|
|
Rex Dieter |
adf30af |
REVIEW: 121306
|
|
Rex Dieter |
adf30af |
---
|
|
Rex Dieter |
adf30af |
server/src/handlerhelper.cpp | 4 ++++
|
|
Rex Dieter |
adf30af |
1 file changed, 4 insertions(+)
|
|
Rex Dieter |
adf30af |
|
|
Rex Dieter |
adf30af |
diff --git a/server/src/handlerhelper.cpp b/server/src/handlerhelper.cpp
|
|
Rex Dieter |
adf30af |
index 634a26c..82347b4 100644
|
|
Rex Dieter |
adf30af |
--- a/server/src/handlerhelper.cpp
|
|
Rex Dieter |
adf30af |
+++ b/server/src/handlerhelper.cpp
|
|
Rex Dieter |
adf30af |
@@ -123,6 +123,10 @@ int HandlerHelper::itemWithFlagsCount( const Collection &col, const QStringList
|
|
Rex Dieter |
adf30af |
// it hits an in-memory cache.
|
|
Rex Dieter |
adf30af |
Q_FOREACH ( const QString &flag, flags ) {
|
|
Rex Dieter |
adf30af |
const Flag f = Flag::retrieveByName( flag );
|
|
Rex Dieter |
adf30af |
+ if (!f.isValid()) {
|
|
Rex Dieter |
adf30af |
+ // since we OR this condition, we can skip invalid flags to speed up the query
|
|
Rex Dieter |
adf30af |
+ continue;
|
|
Rex Dieter |
adf30af |
+ }
|
|
Rex Dieter |
adf30af |
cond.addValueCondition( PimItemFlagRelation::rightFullColumnName(), Query::Equals, f.id() );
|
|
Rex Dieter |
adf30af |
}
|
|
Rex Dieter |
adf30af |
qb.addCondition( cond );
|
|
Rex Dieter |
adf30af |
--
|
|
Rex Dieter |
adf30af |
2.1.0
|
|
Rex Dieter |
adf30af |
|