为student_work表添加索引

为homework_comments添加索引
大幅提高查询速度
This commit is contained in:
huang 2015-11-30 13:09:13 +08:00
parent d67fc18988
commit 39b87aaaac
3 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,5 @@
class AddIndexToHomeworkCommons < ActiveRecord::Migration
def change
add_index :homework_commons, [:course_id, :id]
end
end

View File

@ -0,0 +1,5 @@
class AddIndexToStudentWorks < ActiveRecord::Migration
def change
add_index :student_works, [:homework_common_id, :user_id]
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151127011351) do
ActiveRecord::Schema.define(:version => 20151130033906) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -736,6 +736,8 @@ ActiveRecord::Schema.define(:version => 20151127011351) do
t.integer "anonymous_comment", :default => 0
end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
create_table "homework_detail_manuals", :force => true do |t|
t.float "ta_proportion"
t.integer "comment_status"
@ -961,6 +963,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do
t.integer "course_group_id", :default => 0
end
add_index "members", ["course_id"], :name => "index_members_on_course_id"
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"
@ -1506,6 +1509,8 @@ ActiveRecord::Schema.define(:version => 20151127011351) do
t.boolean "is_test", :default => false
end
add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id"
create_table "student_works_evaluation_distributions", :force => true do |t|
t.integer "student_work_id"
t.integer "user_id"