Add composite index to articles hotness_score and comments_count (#13724)
This commit is contained in:
parent
423b2e8779
commit
860895a7cd
2 changed files with 17 additions and 1 deletions
|
|
@ -0,0 +1,15 @@
|
|||
class AddIndexOnArticlesHotnessScoreCommentsCount < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
columns = %i[hotness_score comments_count]
|
||||
|
||||
add_index :articles, columns, algorithm: :concurrently unless index_exists?(:articles, columns)
|
||||
end
|
||||
|
||||
def down
|
||||
columns = %i[hotness_score comments_count]
|
||||
|
||||
remove_index :articles, column: columns, algorithm: :concurrently if index_exists?(:articles, columns)
|
||||
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_04_30_094954) do
|
||||
ActiveRecord::Schema.define(version: 2021_05_11_073505) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "citext"
|
||||
|
|
@ -161,6 +161,7 @@ ActiveRecord::Schema.define(version: 2021_04_30_094954) do
|
|||
t.index ["comments_count"], name: "index_articles_on_comments_count"
|
||||
t.index ["featured_number"], name: "index_articles_on_featured_number"
|
||||
t.index ["feed_source_url"], name: "index_articles_on_feed_source_url", unique: true
|
||||
t.index ["hotness_score", "comments_count"], name: "index_articles_on_hotness_score_and_comments_count"
|
||||
t.index ["hotness_score"], name: "index_articles_on_hotness_score"
|
||||
t.index ["path"], name: "index_articles_on_path"
|
||||
t.index ["public_reactions_count"], name: "index_articles_on_public_reactions_count", order: :desc
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue