Skip to content

Instantly share code, notes, and snippets.

@joetek
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joetek/6b4ba83d5fcd717cc275 to your computer and use it in GitHub Desktop.
Save joetek/6b4ba83d5fcd717cc275 to your computer and use it in GitHub Desktop.
SQL to restore indexes in WordPress
ALTER TABLE wp_5_posts MODIFY COLUMN ID bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_posts ADD KEY `post_name` (`post_name`);
ALTER TABLE wp_5_posts ADD KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`);
ALTER TABLE wp_5_posts ADD KEY `post_parent` (`post_parent`);
ALTER TABLE wp_5_posts ADD KEY `post_author` (`post_author`);
ALTER TABLE wp_5_postmeta MODIFY COLUMN meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_postmeta ADD KEY `post_id` (`post_id`);
ALTER TABLE wp_5_postmeta ADD KEY `meta_key` (`meta_key`);
ALTER TABLE wp_5_commentmeta MODIFY COLUMN meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_commentmeta ADD KEY `comment_id` (`comment_id`);
ALTER TABLE wp_5_commentmeta ADD KEY `meta_key` (`meta_key`);
ALTER TABLE wp_5_comments MODIFY COLUMN comment_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_comments ADD KEY `comment_post_ID` (`comment_post_ID`);
ALTER TABLE wp_5_comments ADD KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`);
ALTER TABLE wp_5_comments ADD KEY `comment_date_gmt` (`comment_date_gmt`);
ALTER TABLE wp_5_comments ADD KEY `comment_parent` (`comment_parent`);
ALTER TABLE wp_5_terms MODIFY COLUMN term_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_terms ADD KEY `slug` (`slug`);
ALTER TABLE wp_5_terms ADD KEY `name` (`name`);
ALTER TABLE wp_5_term_relationships ADD PRIMARY KEY (`object_id`,`term_taxonomy_id`);
ALTER TABLE wp_5_term_relationships ADD KEY `term_taxonomy_id` (`term_taxonomy_id`);
ALTER TABLE wp_5_term_taxonomy MODIFY COLUMN term_taxonomy_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_term_taxonomy ADD KEY `term_id_taxonomy` (`term_id`,`taxonomy`);
ALTER TABLE wp_5_term_taxonomy ADD KEY `taxonomy` (`taxonomy`);
ALTER TABLE wp_5_links MODIFY COLUMN link_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_links ADD KEY `link_visible` (`link_visible`);
ALTER TABLE wp_5_options MODIFY COLUMN option_id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE wp_5_options ADD KEY `option_name` (`option_name`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment