Skip to content

Commit

Permalink
Temporary prefs buttons to debug slow DB issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed Jan 23, 2017
1 parent c6b78da commit 249f9c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Expand Up @@ -31,6 +31,12 @@
<button id="openAboutMemory"
label="&zotero.preferences.openAboutMemory;"
oncommand="Zotero_Preferences.openInViewer('about:memory')"/>
<button id="db-info"
label="DB Info"
oncommand="Zotero.DB.info().then(json => Zotero.alert(null, '', JSON.stringify(json, null, 4)))"/>
<button id="vacuum"
label="Vacuum DB"
oncommand="Zotero.DB.vacuum().then(() => Zotero.alert(null, '', 'Done'))"/>
</hbox>
</groupbox>
</overlay>
20 changes: 19 additions & 1 deletion chrome/content/zotero/xpcom/db.js
Expand Up @@ -42,7 +42,6 @@ Zotero.DBConnection = function(dbName) {

this.closed = false;
this.skipBackup = false;
this.transactionVacuum = false;

// JS Date
this.__defineGetter__('transactionDate', function () {
Expand Down Expand Up @@ -500,6 +499,8 @@ Zotero.DBConnection.prototype.executeTransaction = Zotero.Promise.coroutine(func
if (options.vacuumOnCommit) {
Zotero.debug('Vacuuming database');
yield this.queryAsync('VACUUM');
Zotero.debug('Done vacuuming');

}

this._transactionID = null;
Expand Down Expand Up @@ -868,6 +869,23 @@ Zotero.DBConnection.prototype.observe = function(subject, topic, data) {
}


// TEMP
Zotero.DBConnection.prototype.vacuum = function () {
return this.executeTransaction(function* () {}, { vacuumOnCommit: true });
};


// TEMP
Zotero.DBConnection.prototype.info = Zotero.Promise.coroutine(function* () {
var info = {};
var pragmas = ['auto_vacuum', 'cache_size', 'locking_mode', 'page_size'];
for (let p of pragmas) {
info[p] = yield Zotero.DB.valueQueryAsync(`PRAGMA ${p}`);
}
return info;
});


Zotero.DBConnection.prototype.integrityCheck = Zotero.Promise.coroutine(function* () {
var ok = yield this.valueQueryAsync("PRAGMA integrity_check");
return ok == 'ok';
Expand Down

0 comments on commit 249f9c6

Please sign in to comment.