Adding possibly missing indices (#16323)

This is meant as a conversation.  Throughout the code-base we have have
`Tag.order(hotness_score: :desc)` and with PR #16322 we'll also have
`Tag.order(taggings_count: :desc)`.

My understanding is that if we have sorting, we might want to consider
an index.  I put this forward as a conversation with a possible quick win.

Related to #16322
This commit is contained in:
Jeremy Friesen 2022-01-27 07:18:51 -05:00 committed by GitHub
parent fa8b55117d
commit 27123bce56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,7 @@
class AddingIndicesToTag < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
add_index :tags, :hotness_score, algorithm: :concurrently
add_index :tags, :taggings_count, algorithm: :concurrently
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_12_22_040359) do
ActiveRecord::Schema.define(version: 2022_01_26_205052) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
@ -1121,9 +1121,11 @@ ActiveRecord::Schema.define(version: 2021_12_22_040359) do
t.datetime "updated_at", null: false
t.text "wiki_body_html"
t.text "wiki_body_markdown"
t.index ["hotness_score"], name: "index_tags_on_hotness_score"
t.index ["name"], name: "index_tags_on_name", unique: true
t.index ["social_preview_template"], name: "index_tags_on_social_preview_template"
t.index ["supported"], name: "index_tags_on_supported"
t.index ["taggings_count"], name: "index_tags_on_taggings_count"
end
create_table "tweets", force: :cascade do |t|