Skip to content

Commit

Permalink
Add indices for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
syndbg committed Oct 14, 2015
1 parent 5547c72 commit e9d90d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddIndicesForBetterPerformance < ActiveRecord::Migration
def change
add_index :questions, :secret
add_index :votes, :question_id
add_index :votes, :option_id
end
end
44 changes: 27 additions & 17 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,36 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20_141_004_134_727) do
create_table 'options', force: true do |t|
t.string 'title'
t.integer 'question_id'
t.datetime 'created_at'
t.datetime 'updated_at'
ActiveRecord::Schema.define(version: 20151014184947) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "options", force: :cascade do |t|
t.string "title"
t.integer "question_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table 'questions', force: true do |t|
t.string 'title'
t.string 'secret'
t.datetime 'created_at'
t.datetime 'updated_at'
create_table "questions", force: :cascade do |t|
t.string "title"
t.string "secret"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table 'votes', force: true do |t|
t.string 'secret'
t.integer 'question_id'
t.integer 'option_id'
t.datetime 'created_at'
t.datetime 'updated_at'
add_index "questions", ["secret"], name: "index_questions_on_secret", using: :btree

create_table "votes", force: :cascade do |t|
t.string "secret"
t.integer "question_id"
t.integer "option_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "votes", ["option_id"], name: "index_votes_on_option_id", using: :btree
add_index "votes", ["question_id"], name: "index_votes_on_question_id", using: :btree

end

0 comments on commit e9d90d3

Please sign in to comment.