From 6c68ca40e4086d9d55cfdb07b47a7e06ab30cef1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Jul 2017 20:33:09 -0400 Subject: [PATCH] add some indexes --- db/zm_update-1.31.3.sql | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/db/zm_update-1.31.3.sql b/db/zm_update-1.31.3.sql index 09a703b97..59f9ef0f7 100644 --- a/db/zm_update-1.31.3.sql +++ b/db/zm_update-1.31.3.sql @@ -74,3 +74,39 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; + +-- +-- Update Monitors table to have an Index on ServerId +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND index_name = 'Monitors_ServerId_idx' + ) > 0, +"SELECT 'Monitors_ServerId Index already exists on Monitors table'", +"CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`)" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + + +-- +-- Update Server table to have an Index on Name +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'Servers' + AND table_schema = DATABASE() + AND index_name = 'Servers_Name_idx' + ) > 0, +"SELECT 'Servers_Name Index already exists on Servers table'", +"CREATE INDEX `Servers_Name_idx` ON `Servers` (`Name`)" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; +