Performance Optimizations:

1. Add index on testrun.submissionId
2. replace lti_parameters.size with lti_parameters.present? to prevent COUNT query

Signed-off-by: Sebastian Serth <Sebastian.Serth@student.hpi.de>
This commit is contained in:
Sebastian Serth
2018-08-23 17:29:14 +02:00
parent 40492479ba
commit 6bd1dac756
3 changed files with 10 additions and 3 deletions

View File

@ -5,6 +5,6 @@ module LtiHelper
lti_parameters = LtiParameter.where(consumers_id: consumer_id,
external_users_id: external_user_id,
exercises_id: exercise_id).lis_outcome_service_url?
!lti_parameters.nil? && lti_parameters.size > 0
!lti_parameters.nil? && lti_parameters.present?
end
end

View File

@ -0,0 +1,5 @@
class AddIndexForTestrunSubmissionId < ActiveRecord::Migration
def change
add_index :testruns, :submission_id
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180815115351) do
ActiveRecord::Schema.define(version: 20180823135317) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -383,6 +383,8 @@ ActiveRecord::Schema.define(version: 20180815115351) do
t.string "cause"
end
add_index "testruns", ["submission_id"], name: "index_testruns_on_submission_id", using: :btree
create_table "user_exercise_feedbacks", force: :cascade do |t|
t.integer "exercise_id", null: false
t.integer "user_id", null: false