PgHero
No long running queries
Connections healthy 15
Vacuuming healthy
No columns near integer overflow
No invalid indexes or constraints
25 duplicate indexes
Query stats must be enabled for slow queries

Duplicate Indexes

These indexes exist, but aren’t needed. Remove them for faster writes.

rails generate migration remove_unneeded_indexes

And paste

remove_index :account_journal, name: "account_journal__company_id_index", column: :company_id
remove_index :account_report_expression, name: "account_report_expression__report_line_id_index", column: :report_line_id
remove_index :account_report_line, name: "account_report_line__report_id_index", column: :report_id
remove_index :calendar_filters, name: "calendar_filters__user_id_index", column: :user_id
remove_index :discuss_call_history, name: "discuss_call_history__start_call_message_id_index", column: :start_call_message_id
remove_index :documents_access, name: "documents_access__document_id_index", column: :document_id
remove_index :documents_document, name: "documents_document__document_token_index", column: :document_token
remove_index :ir_model_constraint, name: "ir_model_constraint__name_index", column: :name
remove_index :ir_model_fields, name: "ir_model_fields__model_index", column: :model
remove_index :ir_model_fields_selection, name: "ir_model_fields_selection__field_id_index", column: :field_id
remove_index :ir_ui_view, name: "ir_ui_view__model_index", column: :model
remove_index :ir_ui_view_custom, name: "ir_ui_view_custom__user_id_index", column: :user_id
remove_index :knowledge_article_favorite, name: "knowledge_article_favorite__article_id_index", column: :article_id
remove_index :mail_followers, name: "mail_followers__res_model_index", column: :res_model
remove_index :mail_message, name: "mail_message_model_res_id_idx", column: [:model, :res_id]
remove_index :mail_message_link_preview, name: "mail_message_link_preview__message_id_index", column: :message_id
remove_index :mail_notification, name: "mail_notification__res_partner_id_index", column: :res_partner_id
remove_index :product_template_attribute_value, name: "product_template_attribute_value__attribute_line_id_index", column: :attribute_line_id
remove_index :project_task_user_rel, name: "project_task_user_rel__task_id_index", column: :task_id
remove_index :res_country_state, name: "res_country_state__country_id_index", column: :country_id
remove_index :res_currency_rate, name: "res_currency_rate__name_index", column: :name
remove_index :res_groups, name: "res_groups__privilege_id_index", column: :privilege_id
remove_index :stock_move, name: "stock_move__product_id_index", column: :product_id
remove_index :stock_warehouse_orderpoint, name: "stock_warehouse_orderpoint__product_id_index", column: :product_id
remove_index :studio_approval_entry, name: "studio_approval_entry__rule_id_index", column: :rule_id
Details
On account_journal
account_journal__company_id_index (company_id)
is covered by
account_journal_code_company_uniq (company_id, code)
On account_report_expression
account_report_expression__report_line_id_index (report_line_id)
is covered by
account_report_expression_line_label_uniq (report_line_id, label)
On account_report_line
account_report_line__report_id_index (report_id)
is covered by
account_report_line_code_uniq (report_id, code)
On calendar_filters
calendar_filters__user_id_index (user_id)
is covered by
calendar_filters_user_id_partner_id_unique (user_id, partner_id)
On discuss_call_history
discuss_call_history__start_call_message_id_index (start_call_message_id)
is covered by
discuss_call_history_message_id_unique_constraint (start_call_message_id)
On documents_access
documents_access__document_id_index (document_id)
is covered by
documents_access_unique_document_access_partner (document_id, partner_id)
On documents_document
documents_document__document_token_index (document_token)
is covered by
documents_document_document_token_unique (document_token)
On ir_model_constraint
ir_model_constraint__name_index (name)
is covered by
ir_model_constraint_module_name_uniq (name, module)
On ir_model_fields
ir_model_fields__model_index (model)
is covered by
ir_model_fields_name_unique (model, name)
On ir_model_fields_selection
ir_model_fields_selection__field_id_index (field_id)
is covered by
ir_model_fields_selection_selection_field_uniq (field_id, value)
On ir_ui_view
ir_ui_view__model_index (model)
is covered by
ir_ui_view_model_type_inherit_id (model, inherit_id)
On ir_ui_view_custom
ir_ui_view_custom__user_id_index (user_id)
is covered by
ir_ui_view_custom_user_id_ref_id (user_id, ref_id)
On knowledge_article_favorite
knowledge_article_favorite__article_id_index (article_id)
is covered by
knowledge_article_favorite_unique_article_user (article_id, user_id)
On mail_followers
mail_followers__res_model_index (res_model)
is covered by
mail_followers_mail_followers_res_partner_res_model_id_uniq (res_model, res_id, partner_id)
On mail_message
mail_message_model_res_id_idx (model, res_id)
is covered by
mail_message_model_res_id_id_idx (model, res_id, id)
On mail_message_link_preview
mail_message_link_preview__message_id_index (message_id)
is covered by
mail_message_link_preview_unique_message_link_preview (message_id, link_preview_id)
On mail_notification
mail_notification__res_partner_id_index (res_partner_id)
is covered by
mail_notification_res_partner_id_is_read_notification__e5e0b7fb (res_partner_id, is_read, notification_status, mail_message_id)
On product_template_attribute_value
product_template_attribute_value__attribute_line_id_index (attribute_line_id)
is covered by
product_template_attribute_value_attribute_value_unique (attribute_line_id, product_attribute_value_id)
On project_task_user_rel
project_task_user_rel__task_id_index (task_id)
is covered by
project_task_user_rel_project_personal_stage_unique (task_id, user_id)
On res_country_state
res_country_state__country_id_index (country_id)
is covered by
res_country_state_name_code_uniq (country_id, code)
On res_currency_rate
res_currency_rate__name_index (name)
is covered by
res_currency_rate_unique_name_per_day (name, currency_id, company_id)
On res_groups
res_groups__privilege_id_index (privilege_id)
is covered by
res_groups_name_uniq (privilege_id, name)
On stock_move
stock_move__product_id_index (product_id)
is covered by
stock_move_product_location_index (product_id, location_id, location_dest_id, company_id, state)
On stock_warehouse_orderpoint
stock_warehouse_orderpoint__product_id_index (product_id)
is covered by
stock_warehouse_orderpoint_product_location_check (product_id, location_id, company_id)
On studio_approval_entry
studio_approval_entry__rule_id_index (rule_id)
is covered by
studio_approval_entry_uniq_combination (rule_id, model, res_id)

Query Stats

Make them available by adding the following lines to postgresql.conf:

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all

Restart the server for the changes to take effect.