From 56dade25981da1656cbb68447e8518529e229978 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Sat, 19 Apr 2014 14:23:50 +0200 Subject: [PATCH 1/2] Fix slow library search on sqlite 3.8. --- src/library/libraryquery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/libraryquery.cpp b/src/library/libraryquery.cpp index cbdc8f99a..5ca51d119 100644 --- a/src/library/libraryquery.cpp +++ b/src/library/libraryquery.cpp @@ -128,7 +128,7 @@ void LibraryQuery::AddWhere(const QString& column, const QVariant& value, } void LibraryQuery::AddCompilationRequirement(bool compilation) { - where_clauses_ << QString("effective_compilation = %1") + where_clauses_ << QString("+effective_compilation = %1") .arg(compilation ? 1 : 0); } From 5fffbbc6898dc8373d6fd5bf28d4cd79d6f089d5 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Tue, 22 Apr 2014 12:25:59 +0200 Subject: [PATCH 2/2] Add explanatory comment to last commit. --- src/library/libraryquery.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/library/libraryquery.cpp b/src/library/libraryquery.cpp index 5ca51d119..02177bf42 100644 --- a/src/library/libraryquery.cpp +++ b/src/library/libraryquery.cpp @@ -128,6 +128,12 @@ void LibraryQuery::AddWhere(const QString& column, const QVariant& value, } void LibraryQuery::AddCompilationRequirement(bool compilation) { + // The unary + is added to prevent sqlite from using the index + // idx_comp_artist. When joining with fts, sqlite 3.8 has a tendency + // to use this index and thereby nesting the tables in an order + // which gives very poor performance. See + // https://github.com/clementine-player/Clementine/pull/4285 for + // more details. where_clauses_ << QString("+effective_compilation = %1") .arg(compilation ? 1 : 0); }