]> git.pld-linux.org Git - packages/akonadi.git/blame - 0018-Optimize-Skip-value-condition-on-invalid-flags.patch
boost rebuild
[packages/akonadi.git] / 0018-Optimize-Skip-value-condition-on-invalid-flags.patch
CommitLineData
8a8f9fb3
AM
1From 7cbff48f5782d1f7f844678e6b785aeb419b0c47 Mon Sep 17 00:00:00 2001
2From: Milian Wolff <mail@milianw.de>
3Date: Mon, 1 Dec 2014 11:59:12 +0100
4Subject: [PATCH 18/30] Optimize: Skip value condition on invalid flags.
5
6HandlerHelper::itemWithFlagsCount gets called quite often apparently
7and I noticed that it was relatively slow from the Query Debugger
8in Akonadi Console. EXPLAIN'ing the query showed that it was using
9a slow-path for the WHERE FOO AND (BAR OR ASDF) condition. Here,
10ASDF was always id = -1, the id of the $IGNORED flag, which
11I apparently don't have. Getting rid of that condition simplifies
12the query to WHERE FOO AND BAR, which is apparently much better
13optimizable. Before, the query often showed a runtime of ~15ms.
14Now it is down to ~9ms.
15
16REVIEW: 121306
17---
18 server/src/handlerhelper.cpp | 4 ++++
19 1 file changed, 4 insertions(+)
20
21diff --git a/server/src/handlerhelper.cpp b/server/src/handlerhelper.cpp
22index 634a26c..82347b4 100644
23--- a/server/src/handlerhelper.cpp
24+++ b/server/src/handlerhelper.cpp
25@@ -123,6 +123,10 @@ int HandlerHelper::itemWithFlagsCount( const Collection &col, const QStringList
26 // it hits an in-memory cache.
27 Q_FOREACH ( const QString &flag, flags ) {
28 const Flag f = Flag::retrieveByName( flag );
29+ if (!f.isValid()) {
30+ // since we OR this condition, we can skip invalid flags to speed up the query
31+ continue;
32+ }
33 cond.addValueCondition( PimItemFlagRelation::rightFullColumnName(), Query::Equals, f.id() );
34 }
35 qb.addCondition( cond );
36--
372.1.0
38
This page took 0.102166 seconds and 4 git commands to generate.