From d0d818840a0176c92019d81ecc761073b4ddfa98 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 9 Jan 2016 16:54:45 -0500 Subject: [PATCH] Switch temp table inserts from SELECT...UNION to VALUES (x),(x)... Supported as of SQLite 3.7.11 Also use hard-coded values instead of bound params --- chrome/content/zotero/xpcom/search.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index 228c7cbbd..1f14ac510 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -941,7 +941,7 @@ Zotero.Search.prototype.loadConditions = Zotero.Promise.coroutine(function* (rel * Batch insert */ Zotero.Search.idsToTempTable = function (ids) { - const N_COMBINED_INSERTS = 128; + const N_COMBINED_INSERTS = 1000; var tmpTable = "tmpSearchResults_" + Zotero.randomString(8); @@ -952,9 +952,9 @@ Zotero.Search.idsToTempTable = function (ids) { var ids2 = ids ? ids.concat() : []; while (ids2.length) { let chunk = ids2.splice(0, N_COMBINED_INSERTS); - let sql = 'INSERT INTO ' + tmpTable + ' ' - + chunk.map(function () "SELECT ?").join(" UNION "); - yield Zotero.DB.queryAsync(sql, chunk, { debug: false }); + let sql = 'INSERT INTO ' + tmpTable + ' VALUES ' + + chunk.map((x) => "(" + parseInt(x) + ")").join(", "); + yield Zotero.DB.queryAsync(sql, false, { debug: false }); } return tmpTable;