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:
parent
fa8b55117d
commit
27123bce56
2 changed files with 10 additions and 1 deletions
7
db/migrate/20220126205052_adding_indices_to_tag.rb
Normal file
7
db/migrate/20220126205052_adding_indices_to_tag.rb
Normal 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
|
||||
|
|
@ -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|
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue