Bug 823156 - Speed up Library downloads query.
authorMarco Bonardo <mbonardo@mozilla.com>
Thu, 20 Dec 2012 14:39:12 +0100
changeset 122197 23da80538e24a7d0a351c3ef2ca042fc1468f2be
parent 122196 7a025808ca170b9dc107e6543d203f3fc668216d
child 122198 022244d0ca81eb5bce06082cc8ba2aa7b575cfb3
push idunknown
push userunknown
push dateunknown
bugs823156
milestone20.0a1
Bug 823156 - Speed up Library downloads query. r=Mano
toolkit/components/places/nsNavHistory.cpp
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -3944,19 +3944,20 @@ nsNavHistory::QueryToSelectClause(nsNavH
       clause.Str("GROUP BY bms.fk HAVING count(*) >=").Param(":tag_count");
     clause.Str(")");
   }
 
   // transitions
   const nsTArray<uint32_t>& transitions = aQuery->Transitions();
   for (uint32_t i = 0; i < transitions.Length(); ++i) {
     nsPrintfCString param(":transition%d_", i);
-    clause.Condition("EXISTS (SELECT 1 FROM moz_historyvisits "
-                             "WHERE place_id = h.id AND visit_type = "
-              ).Param(param.get()).Str(" LIMIT 1)");
+    clause.Condition("h.id IN (SELECT place_id FROM moz_historyvisits "
+                             "WHERE visit_type = ")
+          .Param(param.get())
+          .Str(")");
   }
 
   // folders
   const nsTArray<int64_t>& folders = aQuery->Folders();
   if (folders.Length() > 0) {
     nsTArray<int64_t> includeFolders;
     includeFolders.AppendElements(folders);