Add partial index on users.feed_url (#11411)

This commit is contained in:
rhymes 2020-11-16 17:10:48 +01:00 committed by GitHub
parent d2d9a33323
commit f40975701b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,9 @@
class AddPartialIndexToUsersFeedUrl < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def change
# adds an index only on users with a feed URL, as they are a tiny percentage of the total
# number of users, there is no need to add a full index as most entries will be empty
add_index :users, :feed_url, where: "COALESCE(feed_url, '') <> ''", 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: 2020_10_19_012200) do
ActiveRecord::Schema.define(version: 2020_11_14_151157) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
@ -1328,6 +1328,7 @@ ActiveRecord::Schema.define(version: 2020_10_19_012200) do
t.index ["created_at"], name: "index_users_on_created_at"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["facebook_username"], name: "index_users_on_facebook_username"
t.index ["feed_url"], name: "index_users_on_feed_url", where: "((COALESCE(feed_url, ''::character varying))::text <> ''::text)"
t.index ["github_username"], name: "index_users_on_github_username", unique: true
t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true
t.index ["invitations_count"], name: "index_users_on_invitations_count"