doortts doortts 2017-02-04
fixup! tuning: Reduce issue list page response time
@ca83b1274051070359a812371b8d5bd9155ee34c
conf/evolutions/default/9.sql
--- conf/evolutions/default/9.sql
+++ conf/evolutions/default/9.sql
@@ -1,16 +1,27 @@
 # --- !Ups
-ALTER TABLE issue_comment ADD COLUMN project_id bigint NOT NULL;
+SET FOREIGN_KEY_CHECKS=0;
+
+ALTER TABLE issue_comment ADD COLUMN project_id bigint;
 DELETE FROM issue_comment WHERE issue_id = 0;
 COMMIT;
+
 UPDATE issue_comment a
 SET a.project_id = (SELECT project_id FROM issue b WHERE a.issue_id = b.id);
+
+ALTER TABLE issue_comment MODIFY COLUMN project_id bigint NOT NULL;
+
 CREATE INDEX ix_issue_comment_project_id ON issue_comment (project_id);
 
 ALTER TABLE posting_comment ADD COLUMN project_id bigint NOT NULL;
 DELETE FROM posting_comment WHERE posting_id = 0;
 COMMIT;
+
 UPDATE posting_comment a
 SET a.project_id = (SELECT project_id FROM posting b WHERE a.posting_id = b.id);
+ALTER TABLE posting_comment MODIFY COLUMN project_id bigint NOT NULL;
+
+SET FOREIGN_KEY_CHECKS=1;
+
 CREATE INDEX ix_posting_comment_project_id ON posting_comment (project_id);
 
 CREATE INDEX ix_issue_comment_author_id ON issue_comment (author_id);
@@ -20,7 +31,7 @@
 CREATE INDEX ix_issue_created_date ON issue (created_date);
 
 CREATE INDEX ix_n4user_email ON n4user (email);
-CREATE UNIQUE INDEX uq_email_email_valid ON email (email, valid)
+CREATE UNIQUE INDEX uq_email_email_valid ON email (email, valid);
 
 # --- !Downs
 DROP INDEX ix_issue_comment_project_id ON issue_comment;
Add a comment
List