diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql index d65bd3312..f26d2cc61 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql @@ -336,6 +336,7 @@ CREATE TABLE `guacamole_connection_history` ( KEY `sharing_profile_id` (`sharing_profile_id`), KEY `start_date` (`start_date`), KEY `end_date` (`end_date`), + KEY `connection_start_date` (`connection_id`, `start_date`), CONSTRAINT `guacamole_connection_history_ibfk_1` FOREIGN KEY (`user_id`) @@ -368,6 +369,7 @@ CREATE TABLE guacamole_user_history ( KEY `user_id` (`user_id`), KEY `start_date` (`start_date`), KEY `end_date` (`end_date`), + KEY `user_start_date` (`user_id`, `start_date`), CONSTRAINT guacamole_user_history_ibfk_1 FOREIGN KEY (user_id) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql index 5a0a0b229..ee586bf7a 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql @@ -38,6 +38,12 @@ ALTER TABLE guacamole_connection ALTER TABLE guacamole_connection_history ADD COLUMN remote_host VARCHAR(256) DEFAULT NULL; +-- +-- Add covering index for connection history connection and start date +-- + +ALTER TABLE guacamole_connection_history ADD KEY (connection_id, start_date); + -- -- User login/logout history -- @@ -55,6 +61,7 @@ CREATE TABLE guacamole_user_history ( KEY `user_id` (`user_id`), KEY `start_date` (`start_date`), KEY `end_date` (`end_date`), + KEY `user_start_date` (`user_id`, `start_date`), CONSTRAINT guacamole_user_history_ibfk_1 FOREIGN KEY (user_id) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql index 4840c91d2..97780a541 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql @@ -438,6 +438,9 @@ CREATE INDEX guacamole_connection_history_start_date CREATE INDEX guacamole_connection_history_end_date ON guacamole_connection_history(end_date); +CREATE INDEX guacamole_connection_history_connection_id_start_date + ON guacamole_connection_history(connection_id, start_date); + -- -- User login/logout history -- @@ -468,6 +471,9 @@ CREATE INDEX guacamole_user_history_start_date CREATE INDEX guacamole_user_history_end_date ON guacamole_user_history(end_date); +CREATE INDEX guacamole_user_history_user_id_start_date + ON guacamole_user_history(user_id, start_date); + -- -- User password history -- diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql index 39e8e5991..534d4dcd6 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql @@ -38,6 +38,13 @@ ALTER TABLE guacamole_connection ALTER TABLE guacamole_connection_history ADD COLUMN remote_host VARCHAR(256) DEFAULT NULL; +-- +-- Add covering index for connection history connection and start date +-- + +CREATE INDEX guacamole_connection_history_connection_id_start_date + ON guacamole_connection_history(connection_id, start_date); + -- -- User login/logout history -- @@ -67,3 +74,6 @@ CREATE INDEX guacamole_user_history_start_date CREATE INDEX guacamole_user_history_end_date ON guacamole_user_history(end_date); + +CREATE INDEX guacamole_user_history_user_id_start_date + ON guacamole_user_history(user_id, start_date); diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/schema/001-create-schema.sql index 19d48e464..060503a24 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/schema/001-create-schema.sql +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/schema/001-create-schema.sql @@ -502,6 +502,9 @@ CREATE NONCLUSTERED INDEX [IX_guacamole_connection_history_start_date] CREATE NONCLUSTERED INDEX [IX_guacamole_connection_history_end_date] ON [guacamole_connection_history] ([end_date]); + +CREATE NONCLUSTERED INDEX [IX_guacamole_connection_history_connection_id_start_date] + ON [guacamole_connection_history] ([connection_id], [start_date]); GO -- @@ -533,6 +536,9 @@ CREATE NONCLUSTERED INDEX [IX_guacamole_user_history_start_date] CREATE NONCLUSTERED INDEX [IX_guacamole_user_history_end_date] ON [guacamole_user_history] ([end_date]); + +CREATE NONCLUSTERED INDEX [IX_guacamole_user_history_user_id_start_date] + ON [guacamole_user_history] ([user_id], [start_date]); GO --