-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously any user deletion would scan a very large number of tables This avoids scans on 6 tables/indexes on delete
- Loading branch information
1 parent
be0ae2e
commit c009a6a
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
db/migrate/20190426074404_add_missing_user_destroyer_indexes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class AddMissingUserDestroyerIndexes < ActiveRecord::Migration[5.2] | ||
def change | ||
# these indexes are required to make deletions of users fast | ||
add_index :user_actions, [:target_user_id], where: 'target_user_id IS NOT NULL' | ||
add_index :post_actions, [:user_id] | ||
add_index :user_uploads, [:user_id, :upload_id] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SamSaffron
Author
Member
|
||
add_index :user_auth_token_logs, [:user_id] | ||
add_index :topic_link, [:user_id] | ||
end | ||
end |
This is interesting. Do you know why the unique index wouldn't be used here? I tried it out locally as well and the planner doesn't opt for the unique index.