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
This commit is contained in:
parent
2ac27be95e
commit
d0d818840a
|
@ -941,7 +941,7 @@ Zotero.Search.prototype.loadConditions = Zotero.Promise.coroutine(function* (rel
|
||||||
* Batch insert
|
* Batch insert
|
||||||
*/
|
*/
|
||||||
Zotero.Search.idsToTempTable = function (ids) {
|
Zotero.Search.idsToTempTable = function (ids) {
|
||||||
const N_COMBINED_INSERTS = 128;
|
const N_COMBINED_INSERTS = 1000;
|
||||||
|
|
||||||
var tmpTable = "tmpSearchResults_" + Zotero.randomString(8);
|
var tmpTable = "tmpSearchResults_" + Zotero.randomString(8);
|
||||||
|
|
||||||
|
@ -952,9 +952,9 @@ Zotero.Search.idsToTempTable = function (ids) {
|
||||||
var ids2 = ids ? ids.concat() : [];
|
var ids2 = ids ? ids.concat() : [];
|
||||||
while (ids2.length) {
|
while (ids2.length) {
|
||||||
let chunk = ids2.splice(0, N_COMBINED_INSERTS);
|
let chunk = ids2.splice(0, N_COMBINED_INSERTS);
|
||||||
let sql = 'INSERT INTO ' + tmpTable + ' '
|
let sql = 'INSERT INTO ' + tmpTable + ' VALUES '
|
||||||
+ chunk.map(function () "SELECT ?").join(" UNION ");
|
+ chunk.map((x) => "(" + parseInt(x) + ")").join(", ");
|
||||||
yield Zotero.DB.queryAsync(sql, chunk, { debug: false });
|
yield Zotero.DB.queryAsync(sql, false, { debug: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpTable;
|
return tmpTable;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user