From a5a8c2553bf6f6047d683afe3fc9c20b609aea08 Mon Sep 17 00:00:00 2001 From: eikek Date: Sat, 28 Aug 2021 19:11:13 +0200 Subject: [PATCH] Add indexes to better support certain queries --- .../resources/db/migration/h2/V1.26.0__missing_indexes.sql | 3 +++ .../db/migration/mariadb/V1.26.0__missing_indexes.sql | 3 +++ .../db/migration/postgresql/V1.26.0__missing_indexes.sql | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 modules/store/src/main/resources/db/migration/h2/V1.26.0__missing_indexes.sql create mode 100644 modules/store/src/main/resources/db/migration/mariadb/V1.26.0__missing_indexes.sql create mode 100644 modules/store/src/main/resources/db/migration/postgresql/V1.26.0__missing_indexes.sql diff --git a/modules/store/src/main/resources/db/migration/h2/V1.26.0__missing_indexes.sql b/modules/store/src/main/resources/db/migration/h2/V1.26.0__missing_indexes.sql new file mode 100644 index 00000000..4742ebc3 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/h2/V1.26.0__missing_indexes.sql @@ -0,0 +1,3 @@ +CREATE INDEX "joblog_id_created_idx" ON "joblog"("jid", "created"); +-- H2 doesn't support coalesce in create index +--CREATE INDEX "item_itemdate_created_idx" ON "item"(coalesce("itemdate", "created")); diff --git a/modules/store/src/main/resources/db/migration/mariadb/V1.26.0__missing_indexes.sql b/modules/store/src/main/resources/db/migration/mariadb/V1.26.0__missing_indexes.sql new file mode 100644 index 00000000..32ca1e03 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/mariadb/V1.26.0__missing_indexes.sql @@ -0,0 +1,3 @@ +CREATE INDEX `joblog_id_created_idx` ON `joblog`(`jid`, `created`); +-- MariaDB doesn't support coalesce in index +--CREATE INDEX `item_itemdate_created_idx` ON `item`(coalesce(`itemdate`, `created`)); diff --git a/modules/store/src/main/resources/db/migration/postgresql/V1.26.0__missing_indexes.sql b/modules/store/src/main/resources/db/migration/postgresql/V1.26.0__missing_indexes.sql new file mode 100644 index 00000000..755f36b9 --- /dev/null +++ b/modules/store/src/main/resources/db/migration/postgresql/V1.26.0__missing_indexes.sql @@ -0,0 +1,2 @@ +CREATE INDEX "joblog_id_created_idx" ON "joblog"("jid", "created"); +CREATE INDEX "item_itemdate_created_idx" ON "item"(coalesce("itemdate", "created"));