| @@ -42,9 +42,10 @@ | ||
| 42 | 42 | INDEX `user_id` (`user_id`), |
| 43 | 43 | INDEX `slug` (`slug`), |
| 44 | 44 | INDEX `created_at` (`created_at`), |
| 45 | 45 | INDEX `idx_space_id_status` (`space_id`, `status`), |
| 46 | - INDEX `idx_space_id_status_privacy` (`space_id`, `status`, `privacy`) | |
| 46 | + INDEX `idx_space_id_status_privacy` (`space_id`, `status`, `privacy`), | |
| 47 | + INDEX `idx_status_updated_at` (`status`, `updated_at`) | |
| 47 | 48 | ) $charsetCollate;"; |
| 48 | 49 | dbDelta($sql); |
| 49 | 50 | } else { |
| 50 | 51 | // check if scheduled_at is exist or not |
| @@ -50,8 +51,14 @@ | ||
| 50 | 51 | // check if scheduled_at is exist or not |
| 51 | 52 | $isMigrated = $wpdb->get_col($wpdb->prepare("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND COLUMN_NAME='scheduled_at' AND TABLE_NAME=%s", $table)); |
| 52 | 53 | if(!$isMigrated) { |
| 53 | 54 | $wpdb->query("ALTER TABLE {$table} ADD COLUMN `scheduled_at` DATETIME NULL AFTER `expired_at`"); |
| 55 | + } | |
| 56 | + | |
| 57 | + // check if the ticker index (status, updated_at) exists or not | |
| 58 | + $hasStatusUpdatedIndex = $wpdb->get_col($wpdb->prepare("SELECT INDEX_NAME FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=%s AND INDEX_NAME='idx_status_updated_at'", $table)); | |
| 59 | + if (!$hasStatusUpdatedIndex) { | |
| 60 | + $wpdb->query("ALTER TABLE {$table} ADD INDEX `idx_status_updated_at` (`status`, `updated_at`)"); | |
| 54 | 61 | } |
| 55 | 62 | } |
| 56 | 63 | } |
| 57 | 64 | } |