Merge pull request #1059 from Icinga/schema-index-user_notification_history-retention

schema: Index user_notification_history.notification_history_id
This commit is contained in:
Alvar 2026-01-13 16:03:58 +00:00 committed by GitHub
commit 02415f3a67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View file

@ -1142,7 +1142,9 @@ CREATE TABLE user_notification_history (
PRIMARY KEY (id),
CONSTRAINT fk_user_notification_history_notification_history FOREIGN KEY (notification_history_id) REFERENCES notification_history (id) ON DELETE CASCADE
CONSTRAINT fk_user_notification_history_notification_history FOREIGN KEY (notification_history_id) REFERENCES notification_history (id) ON DELETE CASCADE,
INDEX idx_user_notification_history_notification_history_id (notification_history_id) COMMENT 'Speed up ON DELETE CASCADE'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
CREATE TABLE state_history (

View file

@ -0,0 +1 @@
ALTER TABLE user_notification_history ADD INDEX idx_user_notification_history_notification_history_id (notification_history_id) COMMENT 'Speed up ON DELETE CASCADE';

View file

@ -1840,10 +1840,13 @@ ALTER TABLE user_notification_history ALTER COLUMN environment_id SET STORAGE PL
ALTER TABLE user_notification_history ALTER COLUMN notification_history_id SET STORAGE PLAIN;
ALTER TABLE user_notification_history ALTER COLUMN user_id SET STORAGE PLAIN;
CREATE INDEX idx_user_notification_history_notification_history_id ON user_notification_history(notification_history_id);
COMMENT ON COLUMN user_notification_history.id IS 'sha1(notification_history_id + user_id)';
COMMENT ON COLUMN user_notification_history.environment_id IS 'environment.id';
COMMENT ON COLUMN user_notification_history.notification_history_id IS 'UUID notification_history.id';
COMMENT ON COLUMN user_notification_history.user_id IS 'user.id';
COMMENT ON INDEX idx_user_notification_history_notification_history_id IS 'Speed up ON DELETE CASCADE';
CREATE TABLE state_history (
id bytea20 NOT NULL,

View file

@ -0,0 +1,2 @@
CREATE INDEX idx_user_notification_history_notification_history_id ON user_notification_history(notification_history_id);
COMMENT ON INDEX idx_user_notification_history_notification_history_id IS 'Speed up ON DELETE CASCADE';