1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added indexes on the frequent queries. The problem is still too many queries.

This commit is contained in:
RJ Osborne
2015-05-23 08:48:13 -04:00
parent 2a57cafd6d
commit bec751c4fd
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
class IntroduceIndexes < ActiveRecord::Migration
def change
add_index :weights, :tournament_id
add_index :schools, :tournament_id
add_index :mats, :tournament_id
add_index :matches, :tournament_id
add_index :matches, [:w1, :w2], :unique => true
add_index :wrestlers, :weight_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: 20150517075923) do
ActiveRecord::Schema.define(version: 20150523121319) do
create_table "matches", force: :cascade do |t|
t.integer "w1"
@@ -34,6 +34,9 @@ ActiveRecord::Schema.define(version: 20150517075923) do
t.string "loser2_name"
end
add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id"
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2", unique: true
create_table "mats", force: :cascade do |t|
t.string "name"
t.integer "tournament_id"
@@ -41,6 +44,8 @@ ActiveRecord::Schema.define(version: 20150517075923) do
t.datetime "updated_at"
end
add_index "mats", ["tournament_id"], name: "index_mats_on_tournament_id"
create_table "schools", force: :cascade do |t|
t.string "name"
t.datetime "created_at"
@@ -48,6 +53,8 @@ ActiveRecord::Schema.define(version: 20150517075923) do
t.integer "tournament_id"
end
add_index "schools", ["tournament_id"], name: "index_schools_on_tournament_id"
create_table "tournaments", force: :cascade do |t|
t.string "name"
t.string "address"
@@ -83,6 +90,8 @@ ActiveRecord::Schema.define(version: 20150517075923) do
t.integer "tournament_id"
end
add_index "weights", ["tournament_id"], name: "index_weights_on_tournament_id"
create_table "wrestlers", force: :cascade do |t|
t.string "name"
t.integer "school_id"
@@ -97,4 +106,6 @@ ActiveRecord::Schema.define(version: 20150517075923) do
t.boolean "extra"
end
add_index "wrestlers", ["weight_id"], name: "index_wrestlers_on_weight_id"
end