[Search 2.0] Add index on articles.comments_count (#13599)

This commit is contained in:
rhymes 2021-04-30 15:02:27 +02:00 committed by GitHub
parent 2e9ba2334a
commit 5a1034cab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,15 @@
class AddIndexOnArticlesCommentsCount < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def up
return if index_exists?(:articles, :comments_count)
add_index :articles, :comments_count, algorithm: :concurrently
end
def down
return unless index_exists?(:articles, :comments_count)
remove_index :articles, column: :comments_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_04_29_094116) do
ActiveRecord::Schema.define(version: 2021_04_30_094954) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
@ -158,6 +158,7 @@ ActiveRecord::Schema.define(version: 2021_04_29_094116) do
t.index ["canonical_url"], name: "index_articles_on_canonical_url", unique: true
t.index ["collection_id"], name: "index_articles_on_collection_id"
t.index ["comment_score"], name: "index_articles_on_comment_score"
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"], name: "index_articles_on_hotness_score"