feat: update indexes

This commit is contained in:
Shivam Mishra
2023-06-02 18:25:31 +05:30
parent 0c53e8155c
commit f63a301b17
3 changed files with 4 additions and 6 deletions
+1 -2
View File
@@ -29,12 +29,11 @@
#
# Indexes
#
# index_conversation_with_labels_on_account_id (account_id)
# idx_conv_labels_view__acc_id__status__last_activity (account_id,status,last_activity_at)
# index_conversation_with_labels_on_custom_attributes (custom_attributes) USING gin
# index_conversation_with_labels_on_id (id) UNIQUE
# index_conversation_with_labels_on_labels_array (labels_array) USING gin
# index_conversation_with_labels_on_last_activity_at (last_activity_at)
# index_conversation_with_labels_on_status (status)
#
class ConversationWithLabel < ApplicationRecord
def self.refresh
@@ -4,8 +4,8 @@ class AddIndexToConversationWithLabelsView < ActiveRecord::Migration[7.0]
def change
# needs atleast one unuque index for concurrent refresh
add_index :conversation_with_labels, :id, unique: true, algorithm: :concurrently
add_index :conversation_with_labels, :account_id, algorithm: :concurrently
add_index :conversation_with_labels, :status, algorithm: :concurrently
add_index :conversation_with_labels, [:account_id, :status, :last_activity_at], algorithm: :concurrently,
name: 'idx_conv_labels_view__acc_id__status__last_activity'
add_index :conversation_with_labels, :custom_attributes, using: :gin, algorithm: :concurrently
add_index :conversation_with_labels, :labels_array, using: :gin, algorithm: :concurrently
add_index :conversation_with_labels, :last_activity_at, order: { last_activity_at: :desc }, algorithm: :concurrently
+1 -2
View File
@@ -966,12 +966,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_02_123133) do
LEFT JOIN tags ON ((tags.id = taggings.tag_id)))
GROUP BY conversations.id;
SQL
add_index "conversation_with_labels", ["account_id"], name: "index_conversation_with_labels_on_account_id"
add_index "conversation_with_labels", ["account_id", "status", "last_activity_at"], name: "idx_conv_labels_view__acc_id__status__last_activity"
add_index "conversation_with_labels", ["custom_attributes"], name: "index_conversation_with_labels_on_custom_attributes", using: :gin
add_index "conversation_with_labels", ["id"], name: "index_conversation_with_labels_on_id", unique: true
add_index "conversation_with_labels", ["labels_array"], name: "index_conversation_with_labels_on_labels_array", using: :gin
add_index "conversation_with_labels", ["last_activity_at"], name: "index_conversation_with_labels_on_last_activity_at", order: :desc
add_index "conversation_with_labels", ["status"], name: "index_conversation_with_labels_on_status"
create_trigger("accounts_after_insert_row_tr", :generated => true, :compatibility => 1).
on("accounts").