Put the less-specific column on the left-hand side (#193)

Some database systems can make better use of an index if the index
columns are ordered left-to-right in increasing specificity.  I'm not
sure if Postgres is one of those databases, but it also makes sense to
me to read an index as "ordered by type and then ID".
This commit is contained in:
David Yip 2018-01-27 01:25:22 -06:00
parent c17c07158a
commit 2ce4af84e9
No known key found for this signature in database
GPG Key ID: 7DA0036508FCC0CC
2 changed files with 2 additions and 2 deletions

View File

@ -4,7 +4,7 @@ class CreateGlitchNotes < ActiveRecord::Migration[5.1]
t.bigint :target_id, null: false
t.string :target_type, null: false
t.text :note, null: false
t.index [:target_id, :target_type]
t.index [:target_type, :target_id]
t.timestamps
end
end

View File

@ -188,7 +188,7 @@ ActiveRecord::Schema.define(version: 20180118192721) do
t.text "note", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["target_id", "target_type"], name: "index_glitch_notes_on_target_id_and_target_type"
t.index ["target_type", "target_id"], name: "index_glitch_notes_on_target_type_and_target_id"
end
create_table "imports", force: :cascade do |t|