Redo the database indexes, after some trial and error, to get some significant speed boosts in fetching articles and unread counts.

This commit is contained in:
Brent Simmons 2018-09-25 22:48:47 -07:00
parent d738bff2ad
commit 33fe733a8e
2 changed files with 2 additions and 4 deletions

View File

@ -35,7 +35,7 @@ public final class ArticlesDatabase {
let createStatements = try! NSString(contentsOfFile: createStatementsPath, encoding: String.Encoding.utf8.rawValue)
queue.createTables(usingStatements: createStatements as String)
queue.update { (database) in
database.executeStatements("DROP TABLE if EXISTS tags;DROP INDEX if EXISTS tags_tagName_index;")
database.executeStatements("DROP TABLE if EXISTS tags;DROP INDEX if EXISTS tags_tagName_index;DROP INDEX if EXISTS articles_feedID_index;DROP INDEX if EXISTS statuses_read_index;")
}
queue.vacuumIfNeeded()
}

View File

@ -8,8 +8,6 @@ CREATE TABLE if not EXISTS authorsLookup (authorID TEXT NOT NULL, articleID TEXT
CREATE TABLE if not EXISTS attachments(attachmentID TEXT NOT NULL PRIMARY KEY, url TEXT NOT NULL, mimeType TEXT, title TEXT, sizeInBytes INTEGER, durationInSeconds INTEGER);
CREATE TABLE if not EXISTS attachmentsLookup(attachmentID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(attachmentID, articleID));
CREATE INDEX if not EXISTS articles_feedID_index on articles (feedID);
CREATE INDEX if not EXISTS articles_feedID_datePublished_articleID on articles (feedID, datePublished, articleID);
CREATE INDEX if not EXISTS statuses_read_index on statuses (read);
CREATE INDEX if not EXISTS statuses_starred_index on statuses (starred);