Add missing indexes to improve database query performance (mihonapp/mihon#2950)
(cherry picked from commit cae9fbf3213987e7d263845431dfac10a2ecb3b0)
This commit is contained in:
parent
80ea323281
commit
8bb8d7ccb7
7 changed files with 18 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ CREATE TABLE chapters(
|
|||
|
||||
CREATE INDEX chapters_manga_id_index ON chapters(manga_id);
|
||||
CREATE INDEX chapters_unread_by_manga_index ON chapters(manga_id, read) WHERE read = 0;
|
||||
CREATE INDEX idx_chapters_url ON chapters(url);
|
||||
|
||||
CREATE TRIGGER update_last_modified_at_chapters
|
||||
AFTER UPDATE ON chapters
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ CREATE TABLE excluded_scanlators(
|
|||
);
|
||||
|
||||
CREATE INDEX excluded_scanlators_manga_id_index ON excluded_scanlators(manga_id);
|
||||
CREATE INDEX idx_excluded_scanlators_scanlator ON excluded_scanlators(scanlator);
|
||||
|
||||
insert:
|
||||
INSERT INTO excluded_scanlators(manga_id, scanlator)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ CREATE TABLE history(
|
|||
);
|
||||
|
||||
CREATE INDEX history_history_chapter_id_index ON history(chapter_id);
|
||||
CREATE INDEX idx_history_last_read ON history(last_read);
|
||||
|
||||
getHistoryByMangaId:
|
||||
SELECT
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ CREATE TABLE manga_sync(
|
|||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_manga_sync_manga_id ON manga_sync(manga_id);
|
||||
|
||||
delete:
|
||||
DELETE FROM manga_sync
|
||||
WHERE manga_id = :mangaId AND sync_id = :syncId;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ CREATE TABLE mangas(
|
|||
|
||||
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
|
||||
CREATE INDEX mangas_url_index ON mangas(url);
|
||||
CREATE INDEX idx_mangas_source ON mangas(source);
|
||||
|
||||
CREATE TRIGGER update_last_favorited_at_mangas
|
||||
AFTER UPDATE OF favorite ON mangas
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ CREATE TABLE mangas_categories(
|
|||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_mangas_categories_manga_id ON mangas_categories(manga_id);
|
||||
CREATE INDEX idx_mangas_categories_category_id ON mangas_categories(category_id);
|
||||
|
||||
CREATE TRIGGER insert_manga_category_update_version AFTER INSERT ON mangas_categories
|
||||
BEGIN
|
||||
UPDATE mangas
|
||||
|
|
|
|||
9
data/src/main/sqldelight/tachiyomi/migrations/45.sqm
Normal file
9
data/src/main/sqldelight/tachiyomi/migrations/45.sqm
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-- Migration to add performance indexes
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_mangas_source ON mangas(source);
|
||||
CREATE INDEX IF NOT EXISTS idx_chapters_url ON chapters(url);
|
||||
CREATE INDEX IF NOT EXISTS idx_mangas_categories_manga_id ON mangas_categories(manga_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_mangas_categories_category_id ON mangas_categories(category_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_excluded_scanlators_scanlator ON excluded_scanlators(scanlator);
|
||||
CREATE INDEX IF NOT EXISTS idx_manga_sync_manga_id ON manga_sync(manga_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_history_last_read ON history(last_read);
|
||||
Loading…
Reference in a new issue