From ba571f44588aa76debe215b3d2ed84281be2f075 Mon Sep 17 00:00:00 2001 From: Maciej Walkowiak Date: Sat, 9 Dec 2023 00:51:17 +0100 Subject: [PATCH] Add database indexes in schema files. Fixes #403 --- .../src/main/resources/schema-h2.sql | 4 +++- .../src/main/resources/schema-mysql.sql | 6 ++++-- .../src/main/resources/schema-postgresql.sql | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-h2.sql b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-h2.sql index cbb4c58d7..d6cb9a64d 100644 --- a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-h2.sql +++ b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-h2.sql @@ -7,4 +7,6 @@ CREATE TABLE IF NOT EXISTS EVENT_PUBLICATION PUBLICATION_DATE TIMESTAMP(9) WITH TIME ZONE NOT NULL, SERIALIZED_EVENT VARCHAR(4000) NOT NULL, PRIMARY KEY (ID) -) +); +CREATE INDEX IF NOT EXISTS EVENT_PUBLICATION_LISTENER_ID_SERIALIZED_EVENT_IDX ON EVENT_PUBLICATION (LISTENER_ID, SERIALIZED_EVENT); +CREATE INDEX IF NOT EXISTS EVENT_PUBLICATION_COMPLETION_DATE_IDX ON EVENT_PUBLICATION (COMPLETION_DATE); diff --git a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-mysql.sql b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-mysql.sql index 3b465a508..92b172606 100644 --- a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-mysql.sql +++ b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-mysql.sql @@ -6,5 +6,7 @@ CREATE TABLE IF NOT EXISTS EVENT_PUBLICATION SERIALIZED_EVENT VARCHAR(4000) NOT NULL, PUBLICATION_DATE TIMESTAMP(6) NOT NULL, COMPLETION_DATE TIMESTAMP(6) DEFAULT NULL NULL, - PRIMARY KEY (ID) -) + PRIMARY KEY (ID), + INDEX EVENT_PUBLICATION_LISTENER_ID_IDX (LISTENER_ID), + INDEX EVENT_PUBLICATION_COMPLETION_DATE_IDX (COMPLETION_DATE) +); diff --git a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-postgresql.sql b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-postgresql.sql index bd8bd6d70..5e23373e3 100644 --- a/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-postgresql.sql +++ b/spring-modulith-events/spring-modulith-events-jdbc/src/main/resources/schema-postgresql.sql @@ -7,4 +7,6 @@ CREATE TABLE IF NOT EXISTS event_publication publication_date TIMESTAMP WITH TIME ZONE NOT NULL, completion_date TIMESTAMP WITH TIME ZONE, PRIMARY KEY (id) -) +); +CREATE INDEX IF NOT EXISTS event_publication_listener_id_serialized_event_idx ON event_publication (listener_id, serialized_event); +CREATE INDEX IF NOT EXISTS event_publication_completion_date_idx ON event_publication (completion_date);