Group SQL statements run during items list load into transactions -- this should greatly help avoid slowdown caused by new child items handling
Clear Notifier queue before triggering, so that any commits in triggered code don't result in an infinite loop
This commit is contained in:
parent
d8366f3e3c
commit
0a966cac12
|
@ -893,8 +893,11 @@ Zotero.ItemGroup.prototype.getSearchObject = function() {
|
|||
|
||||
// Create/load the inner search
|
||||
var s = new Zotero.Search();
|
||||
if (this.isLibrary()) { }
|
||||
if (this.isLibrary()) {
|
||||
s.addCondition('noChildren', 'true');
|
||||
}
|
||||
else if (this.isCollection()) {
|
||||
s.addCondition('noChildren', 'true');
|
||||
s.addCondition('collectionID', 'is', this.ref.getID());
|
||||
if (Zotero.Prefs.get('recursiveCollections')) {
|
||||
s.addCondition('recursive', 'true');
|
||||
|
|
|
@ -188,6 +188,8 @@ Zotero.ItemTreeView.prototype.refresh = function()
|
|||
cacheFields = cacheFields.concat(field);
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
Zotero.Items.cacheFields(cacheFields);
|
||||
|
||||
var newRows = this._itemGroup.getChildItems();
|
||||
|
@ -221,6 +223,8 @@ Zotero.ItemTreeView.prototype.refresh = function()
|
|||
}
|
||||
}
|
||||
|
||||
Zotero.DB.commitTransaction();
|
||||
|
||||
this._refreshHashMap();
|
||||
|
||||
// Update the treebox's row count
|
||||
|
|
|
@ -249,6 +249,8 @@ Zotero.Notifier = new function(){
|
|||
}
|
||||
}
|
||||
|
||||
reset();
|
||||
|
||||
if (totals) {
|
||||
Zotero.debug("Committing Notifier event queue" + totals);
|
||||
|
||||
|
@ -261,7 +263,6 @@ Zotero.Notifier = new function(){
|
|||
}
|
||||
}
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -341,10 +341,13 @@ Zotero.Search.prototype.search = function(asTempTable){
|
|||
}
|
||||
|
||||
if (this._scope) {
|
||||
Zotero.DB.beginTransaction();
|
||||
|
||||
// If subsearch has post-search filter, run and insert ids into temp table
|
||||
if (this._scope.hasPostSearchFilter()) {
|
||||
var ids = this._scope.search();
|
||||
if (!ids) {
|
||||
Zotero.DB.commitTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -375,6 +378,7 @@ Zotero.Search.prototype.search = function(asTempTable){
|
|||
|
||||
var ids = Zotero.DB.columnQuery(sql, this._sqlParams);
|
||||
Zotero.DB.query("DROP TABLE " + tmpTable);
|
||||
Zotero.DB.commitTransaction();
|
||||
}
|
||||
else {
|
||||
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
|
||||
|
@ -528,6 +532,8 @@ Zotero.Search.prototype.getSQLParams = function(){
|
|||
Zotero.Search.prototype._idsToTempTable = function (ids) {
|
||||
var tmpTable = "tmpSearchResults_" + Zotero.randomString(8);
|
||||
|
||||
Zotero.DB.beginTransaction();
|
||||
|
||||
var sql = "CREATE TEMPORARY TABLE " + tmpTable + " (itemID INT)";
|
||||
Zotero.DB.query(sql);
|
||||
var sql = "INSERT INTO " + tmpTable + " VALUES (?)";
|
||||
|
@ -546,6 +552,8 @@ Zotero.Search.prototype._idsToTempTable = function (ids) {
|
|||
var sql = "CREATE INDEX " + tmpTable + "_itemID ON " + tmpTable + "(itemID)";
|
||||
Zotero.DB.query(sql);
|
||||
|
||||
Zotero.DB.commitTransaction();
|
||||
|
||||
return tmpTable;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user