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:
Dan Stillman 2007-04-27 06:36:00 +00:00
parent d8366f3e3c
commit 0a966cac12
4 changed files with 18 additions and 2 deletions

View File

@ -893,8 +893,11 @@ Zotero.ItemGroup.prototype.getSearchObject = function() {
// Create/load the inner search // Create/load the inner search
var s = new Zotero.Search(); var s = new Zotero.Search();
if (this.isLibrary()) { } if (this.isLibrary()) {
s.addCondition('noChildren', 'true');
}
else if (this.isCollection()) { else if (this.isCollection()) {
s.addCondition('noChildren', 'true');
s.addCondition('collectionID', 'is', this.ref.getID()); s.addCondition('collectionID', 'is', this.ref.getID());
if (Zotero.Prefs.get('recursiveCollections')) { if (Zotero.Prefs.get('recursiveCollections')) {
s.addCondition('recursive', 'true'); s.addCondition('recursive', 'true');

View File

@ -188,6 +188,8 @@ Zotero.ItemTreeView.prototype.refresh = function()
cacheFields = cacheFields.concat(field); cacheFields = cacheFields.concat(field);
} }
} }
Zotero.DB.beginTransaction();
Zotero.Items.cacheFields(cacheFields); Zotero.Items.cacheFields(cacheFields);
var newRows = this._itemGroup.getChildItems(); var newRows = this._itemGroup.getChildItems();
@ -221,6 +223,8 @@ Zotero.ItemTreeView.prototype.refresh = function()
} }
} }
Zotero.DB.commitTransaction();
this._refreshHashMap(); this._refreshHashMap();
// Update the treebox's row count // Update the treebox's row count

View File

@ -249,6 +249,8 @@ Zotero.Notifier = new function(){
} }
} }
reset();
if (totals) { if (totals) {
Zotero.debug("Committing Notifier event queue" + totals); Zotero.debug("Committing Notifier event queue" + totals);
@ -261,7 +263,6 @@ Zotero.Notifier = new function(){
} }
} }
} }
reset();
} }

View File

@ -341,10 +341,13 @@ Zotero.Search.prototype.search = function(asTempTable){
} }
if (this._scope) { if (this._scope) {
Zotero.DB.beginTransaction();
// If subsearch has post-search filter, run and insert ids into temp table // If subsearch has post-search filter, run and insert ids into temp table
if (this._scope.hasPostSearchFilter()) { if (this._scope.hasPostSearchFilter()) {
var ids = this._scope.search(); var ids = this._scope.search();
if (!ids) { if (!ids) {
Zotero.DB.commitTransaction();
return false; return false;
} }
@ -375,6 +378,7 @@ Zotero.Search.prototype.search = function(asTempTable){
var ids = Zotero.DB.columnQuery(sql, this._sqlParams); var ids = Zotero.DB.columnQuery(sql, this._sqlParams);
Zotero.DB.query("DROP TABLE " + tmpTable); Zotero.DB.query("DROP TABLE " + tmpTable);
Zotero.DB.commitTransaction();
} }
else { else {
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams); var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
@ -528,6 +532,8 @@ Zotero.Search.prototype.getSQLParams = function(){
Zotero.Search.prototype._idsToTempTable = function (ids) { Zotero.Search.prototype._idsToTempTable = function (ids) {
var tmpTable = "tmpSearchResults_" + Zotero.randomString(8); var tmpTable = "tmpSearchResults_" + Zotero.randomString(8);
Zotero.DB.beginTransaction();
var sql = "CREATE TEMPORARY TABLE " + tmpTable + " (itemID INT)"; var sql = "CREATE TEMPORARY TABLE " + tmpTable + " (itemID INT)";
Zotero.DB.query(sql); Zotero.DB.query(sql);
var sql = "INSERT INTO " + tmpTable + " VALUES (?)"; 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)"; var sql = "CREATE INDEX " + tmpTable + "_itemID ON " + tmpTable + "(itemID)";
Zotero.DB.query(sql); Zotero.DB.query(sql);
Zotero.DB.commitTransaction();
return tmpTable; return tmpTable;
} }