mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
feat: add index to conversation id and account_id (#6757)
- This PR adds an index to conversations id and account_id. This improves the performance of some reports query
This commit is contained in:
4
Gemfile
4
Gemfile
@@ -165,6 +165,10 @@ group :development do
|
|||||||
|
|
||||||
# When we want to squash migrations
|
# When we want to squash migrations
|
||||||
gem 'squasher'
|
gem 'squasher'
|
||||||
|
|
||||||
|
# profiling
|
||||||
|
gem 'rack-mini-profiler', require: false
|
||||||
|
gem 'stackprof'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|||||||
@@ -520,6 +520,8 @@ GEM
|
|||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rack-cors (1.1.1)
|
rack-cors (1.1.1)
|
||||||
rack (>= 2.0.0)
|
rack (>= 2.0.0)
|
||||||
|
rack-mini-profiler (3.0.0)
|
||||||
|
rack (>= 1.2.0)
|
||||||
rack-protection (3.0.5)
|
rack-protection (3.0.5)
|
||||||
rack
|
rack
|
||||||
rack-proxy (0.7.2)
|
rack-proxy (0.7.2)
|
||||||
@@ -692,6 +694,7 @@ GEM
|
|||||||
activesupport (>= 5.2)
|
activesupport (>= 5.2)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
squasher (0.6.2)
|
squasher (0.6.2)
|
||||||
|
stackprof (0.2.24)
|
||||||
statsd-ruby (1.5.0)
|
statsd-ruby (1.5.0)
|
||||||
stripe (6.5.0)
|
stripe (6.5.0)
|
||||||
telephone_number (1.4.16)
|
telephone_number (1.4.16)
|
||||||
@@ -840,6 +843,7 @@ DEPENDENCIES
|
|||||||
pundit
|
pundit
|
||||||
rack-attack
|
rack-attack
|
||||||
rack-cors
|
rack-cors
|
||||||
|
rack-mini-profiler
|
||||||
rack-timeout
|
rack-timeout
|
||||||
rails (~> 6.1, >= 6.1.7.3)
|
rails (~> 6.1, >= 6.1.7.3)
|
||||||
redis
|
redis
|
||||||
@@ -865,6 +869,7 @@ DEPENDENCIES
|
|||||||
spring
|
spring
|
||||||
spring-watcher-listen
|
spring-watcher-listen
|
||||||
squasher
|
squasher
|
||||||
|
stackprof
|
||||||
stripe
|
stripe
|
||||||
telephone_number
|
telephone_number
|
||||||
test-prof
|
test-prof
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
# index_conversations_on_contact_id (contact_id)
|
# index_conversations_on_contact_id (contact_id)
|
||||||
# index_conversations_on_contact_inbox_id (contact_inbox_id)
|
# index_conversations_on_contact_inbox_id (contact_inbox_id)
|
||||||
# index_conversations_on_first_reply_created_at (first_reply_created_at)
|
# index_conversations_on_first_reply_created_at (first_reply_created_at)
|
||||||
|
# index_conversations_on_id_and_account_id (account_id,id)
|
||||||
# index_conversations_on_inbox_id (inbox_id)
|
# index_conversations_on_inbox_id (inbox_id)
|
||||||
# index_conversations_on_last_activity_at (last_activity_at)
|
# index_conversations_on_last_activity_at (last_activity_at)
|
||||||
# index_conversations_on_status_and_account_id (status,account_id)
|
# index_conversations_on_status_and_account_id (status,account_id)
|
||||||
|
|||||||
8
config/initializers/rack_profiler.rb
Normal file
8
config/initializers/rack_profiler.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
if Rails.env.development?
|
||||||
|
require 'rack-mini-profiler'
|
||||||
|
|
||||||
|
# initialization is skipped so trigger it
|
||||||
|
Rack::MiniProfilerRails.initialize!(Rails.application)
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class AddIndexToConversationsAccountIdAndId < ActiveRecord::Migration[6.1]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :conversations, [:account_id, :id], name: 'index_conversations_on_id_and_account_id', algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2023_03_15_105847) do
|
ActiveRecord::Schema.define(version: 2023_03_27_081350) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_stat_statements"
|
enable_extension "pg_stat_statements"
|
||||||
@@ -448,6 +448,7 @@ ActiveRecord::Schema.define(version: 2023_03_15_105847) do
|
|||||||
t.datetime "assignee_last_seen_at"
|
t.datetime "assignee_last_seen_at"
|
||||||
t.datetime "first_reply_created_at"
|
t.datetime "first_reply_created_at"
|
||||||
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
|
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
|
||||||
|
t.index ["account_id", "id"], name: "index_conversations_on_id_and_account_id"
|
||||||
t.index ["account_id", "inbox_id", "status", "assignee_id"], name: "conv_acid_inbid_stat_asgnid_idx"
|
t.index ["account_id", "inbox_id", "status", "assignee_id"], name: "conv_acid_inbid_stat_asgnid_idx"
|
||||||
t.index ["account_id"], name: "index_conversations_on_account_id"
|
t.index ["account_id"], name: "index_conversations_on_account_id"
|
||||||
t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id"
|
t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id"
|
||||||
|
|||||||
Reference in New Issue
Block a user