From 0af5f5c4d94014e939ca806dbbcbb83cc75b400f Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 15 Jul 2022 22:20:10 +0800 Subject: [PATCH] perf: add database indices for faster querying --- .../sqlite/V20220715213721__perf_indices.sql | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 komga/src/flyway/resources/db/migration/sqlite/V20220715213721__perf_indices.sql diff --git a/komga/src/flyway/resources/db/migration/sqlite/V20220715213721__perf_indices.sql b/komga/src/flyway/resources/db/migration/sqlite/V20220715213721__perf_indices.sql new file mode 100644 index 000000000..c07827c78 --- /dev/null +++ b/komga/src/flyway/resources/db/migration/sqlite/V20220715213721__perf_indices.sql @@ -0,0 +1,31 @@ +-- missing foreign key indices +create index if not exists idx__book_metadata_link__book_id + on BOOK_METADATA_LINK (BOOK_ID); +create index if not exists idx__series_metadata_sharing__series_id + on SERIES_METADATA_SHARING (SERIES_ID); +create index if not exists idx__book_metadata_aggregation_tag__series_id + on BOOK_METADATA_AGGREGATION_TAG (SERIES_ID); +create index if not exists idx__thumbnail_collection__collection_id + on THUMBNAIL_COLLECTION (COLLECTION_ID); +create index if not exists idx__thumbnail_readlist__readlist_id + on THUMBNAIL_READLIST (READLIST_ID); +create index if not exists idx__thumbnail_series__series_id + on THUMBNAIL_SERIES (SERIES_ID); +create index if not exists idx__authentication_activity__user_id + on AUTHENTICATION_ACTIVITY (USER_ID); + +-- if you sort by it, index it +create index if not exists idx__book_metadata__number_sort + on BOOK_METADATA (NUMBER_SORT); +create index if not exists idx__series__last_modified_date + on SERIES (LAST_MODIFIED_DATE); +create index if not exists idx__series__created_date + on SERIES (CREATED_DATE); +create index if not exists idx__book_metadata__release_date + on BOOK_METADATA (RELEASE_DATE); +create index if not exists idx__book__created_date + on BOOK (CREATED_DATE); +create index if not exists idx__read_progress__last_modified_date + on READ_PROGRESS (LAST_MODIFIED_DATE); +create index if not exists idx__media__status + on MEDIA (STATUS);