Add an index on itemData.valueID

Hopefully this will drastically speed up purging after people delete
huge numbers of items.

https://forums.zotero.org/discussion/comment/466885/#Comment_466885
This commit is contained in:
Dan Stillman 2024-07-01 01:28:27 -04:00
parent 16ae145d6c
commit cc3bdb59c1
3 changed files with 6 additions and 4 deletions

View file

@ -503,7 +503,7 @@ Zotero.Items = function() {
}
catch (e) {
if (e.message.includes('no such column: IA.authorName')
&& await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM version WHERE schema='userdata' AND version IN (120, 121)")) {
&& await Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM version WHERE schema='userdata' AND version IN (120, 121, 122)")) {
await Zotero.DB.queryAsync("UPDATE version SET version=119 WHERE schema='userdata'");
Zotero.crash();
}

View file

@ -3455,8 +3455,9 @@ Zotero.Schema = new function(){
await Zotero.DB.queryAsync("REPLACE INTO fileTypeMIMETypes VALUES(8, 'application/epub')");
}
// TEMP: When adding 123, check whether IA.authorName fix in items.js::_loadAnnotations()
// can be updated due to update steps being indempodent
else if (i == 123) {
await Zotero.DB.queryAsync("CREATE INDEX itemData_valueID ON itemData(valueID)");
}
// If breaking compatibility or doing anything dangerous, clear minorUpdateFrom
}

View file

@ -1,4 +1,4 @@
-- 122
-- 123
-- Copyright (c) 2009 Center for History and New Media
-- George Mason University, Fairfax, Virginia, USA
@ -186,6 +186,7 @@ CREATE TABLE itemData (
FOREIGN KEY (valueID) REFERENCES itemDataValues(valueID)
);
CREATE INDEX itemData_fieldID ON itemData(fieldID);
CREATE INDEX itemData_valueID ON itemData(valueID);
-- Note data for note and attachment items
CREATE TABLE itemNotes (