From b4981058a24a150c55626d515358612aa0f61a12 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 22 Apr 2022 14:03:07 +0200 Subject: [PATCH] Add indexes to creational tables (#6974) --- app/src/main/sqldelight/data/chapters.sq | 3 +++ app/src/main/sqldelight/data/history.sq | 2 ++ app/src/main/sqldelight/data/mangas.sq | 3 +++ 3 files changed, 8 insertions(+) diff --git a/app/src/main/sqldelight/data/chapters.sq b/app/src/main/sqldelight/data/chapters.sq index e368d56f2..337b1163c 100644 --- a/app/src/main/sqldelight/data/chapters.sq +++ b/app/src/main/sqldelight/data/chapters.sq @@ -15,6 +15,9 @@ CREATE TABLE chapters( ON DELETE CASCADE ); +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; + getChapterById: SELECT * FROM chapters diff --git a/app/src/main/sqldelight/data/history.sq b/app/src/main/sqldelight/data/history.sq index 1eb68f1e8..a798b325a 100644 --- a/app/src/main/sqldelight/data/history.sq +++ b/app/src/main/sqldelight/data/history.sq @@ -9,6 +9,8 @@ CREATE TABLE history( ON DELETE CASCADE ); +CREATE INDEX history_history_chapter_id_index ON history(history_chapter_id); + resetHistoryById: UPDATE history SET history_last_read = 0 diff --git a/app/src/main/sqldelight/data/mangas.sq b/app/src/main/sqldelight/data/mangas.sq index 09c57ae49..30b462be6 100644 --- a/app/src/main/sqldelight/data/mangas.sq +++ b/app/src/main/sqldelight/data/mangas.sq @@ -22,6 +22,9 @@ CREATE TABLE mangas( date_added INTEGER AS Long NOT NULL ); +CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1; +CREATE INDEX mangas_url_index ON mangas(url); + getMangaById: SELECT * FROM mangas