Add index to notifications to optimize query (#5921) [deploy]
- Index notifications on notifiable_id, notifiable_type, and action
This commit is contained in:
parent
00fefe5865
commit
231e8d49b2
2 changed files with 13 additions and 1 deletions
|
|
@ -0,0 +1,10 @@
|
|||
class AddNotifiableIdNotifiableTypeActionIndexToNotifications < ActiveRecord::Migration[5.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :notifications, %i[notifiable_id notifiable_type action],
|
||||
unique: false,
|
||||
name: "index_notifications_on_notifiable_id_notifiable_type_and_action",
|
||||
algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,8 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_01_20_053525) do
|
||||
ActiveRecord::Schema.define(version: 2020_02_05_225813) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -581,6 +582,7 @@ ActiveRecord::Schema.define(version: 2020_01_20_053525) do
|
|||
t.integer "user_id"
|
||||
t.index ["created_at"], name: "index_notifications_on_created_at"
|
||||
t.index ["json_data"], name: "index_notifications_on_json_data", using: :gin
|
||||
t.index ["notifiable_id", "notifiable_type", "action"], name: "index_notifications_on_notifiable_id_notifiable_type_and_action"
|
||||
t.index ["notifiable_id"], name: "index_notifications_on_notifiable_id"
|
||||
t.index ["notifiable_type"], name: "index_notifications_on_notifiable_type"
|
||||
t.index ["notified_at"], name: "index_notifications_on_notified_at"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue